From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751275AbcBMTCf (ORCPT ); Sat, 13 Feb 2016 14:02:35 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:1939 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750987AbcBMTCe (ORCPT ); Sat, 13 Feb 2016 14:02:34 -0500 X-IronPort-AV: E=Sophos;i="5.22,441,1449529200"; d="scan'208";a="164599428" Date: Sat, 13 Feb 2016 20:02:32 +0100 (CET) From: Julia Lawall X-X-Sender: jll@localhost6.localdomain6 To: Amitoj Kaur Chawla cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] goldfish: Return correct error code In-Reply-To: <20160213144153.GA19589@amitoj-Inspiron-3542> Message-ID: References: <20160213144153.GA19589@amitoj-Inspiron-3542> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 13 Feb 2016, Amitoj Kaur Chawla wrote: > The return value of devm_kzalloc on failure of allocation of memory > should be -ENOMEM and not -1. > > Found using Coccinelle. A simplified version of the semantic patch > used is: > > // > @@ > expression *e; > @@ > > e = devm_kzalloc(...); > if (e == NULL) { > ... > return > - -1 > + -ENOMEM > ; > } > // > > The single call site does not perform any checks on the return value, > hence no change is required at the call site. > > Signed-off-by: Amitoj Kaur Chawla > --- > drivers/platform/goldfish/goldfish_pipe.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c > index e7a29e2..f15e3c9 100644 > --- a/drivers/platform/goldfish/goldfish_pipe.c > +++ b/drivers/platform/goldfish/goldfish_pipe.c > @@ -222,7 +222,7 @@ static int setup_access_params_addr(struct platform_device *pdev, > > aps = devm_kzalloc(&pdev->dev, sizeof(struct access_params), GFP_KERNEL); > if (!aps) > - return -1; > + return -ENOMEM; > > /* FIXME */ > paddr = __pa(aps); There is another return -1 at the end of the function that should be addressed. Maybe -EINVAL would be an appropriate value, if you don't find evidence of anything else. julia