Received: by 10.223.148.5 with SMTP id 5csp7491323wrq; Thu, 18 Jan 2018 06:12:13 -0800 (PST) X-Google-Smtp-Source: ACJfBoshdYcTjek82MS+ij2vC+ipcxeMphnloWbTnPhfcBaibrTMJWeZntmmGWe0jhv8lXCoiS7W X-Received: by 10.99.110.78 with SMTP id j75mr36050322pgc.96.1516284733495; Thu, 18 Jan 2018 06:12:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516284733; cv=none; d=google.com; s=arc-20160816; b=l467oPcZXgx7j9kcVjqm0G7kj48EWRb8TI45r/q/eDmgLXQ1N32+zFU9IWJQUfgBZv LZwb2ZK+c9Tka+UhPbD0SUPFBbiG8woNgSA/fK74o/8LwcglRu+fgqoDkfzZLC8xjtFy pBSx6qN5Hs5rtYCsAM6uOJ2RiZT9IlPgI0FZkvuXAMybfHiwcjWOlW74fVBELKL64VlJ zN8sd2c301krdKL/i7rmhw9Xz0Bd1lvA5isvtoJHJFOcEZId+xy4k75lOwecsNoFomU/ vLlBV2/+hqfxFiR1K6vJ7U6ATyZ8RQ4y2pY3ViDycmHcjMrABEBz+RaYRKOcEZg3nDsj +jYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=1MysIYQn3QIvdVMeKRVYjQ/oLfnuh4IWSWNIyqAd84Y=; b=J3POYmNtBomVSwRdIK6v6G79XA5JFGYbEyHdywnTGNCzL7uwZk+0X6xJFF6tflrtIH CT9A6XZCZ8QHfHZ4ZGaaWzCQddH5iPq+EMqW8CbW1qXnuFLaOc81AVedEbP7WD8qhFda EAexmVF6v934s2IiqtXljDb7/+zGhVrR2fJ+rKswc1N9YfaEGUD1ssFqsgAEnssMTADR vQGz+hU93EbQi1K+a5xDdXGSMLbfsM3MzHwYnVy0qKuA4fdBBjKTwodKW3fV36259jqz Fu8q3nqdV3wAm+/0DQYUsUN84lYdSy9YQYe6EiGF0x2v4O+VzQiHI48VBvG0okBvT5ki UsEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w18si6278989pgm.799.2018.01.18.06.11.58; Thu, 18 Jan 2018 06:12:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756454AbeAROLf (ORCPT + 99 others); Thu, 18 Jan 2018 09:11:35 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:35968 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756267AbeAROLe (ORCPT ); Thu, 18 Jan 2018 09:11:34 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 485D62091A; Thu, 18 Jan 2018 15:11:32 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id E5800208F6; Thu, 18 Jan 2018 15:11:31 +0100 (CET) Date: Thu, 18 Jan 2018 15:11:32 +0100 From: Boris Brezillon To: Wei Yongjun Cc: Artem Bityutskiy , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , , , Subject: Re: [PATCH -next] mtd: ubi: wl: Fix error return code in ubi_wl_init() Message-ID: <20180118151132.255e0173@bbrezillon> In-Reply-To: <20180118150801.714ecc34@bbrezillon> References: <1516284305-82544-1-git-send-email-weiyongjun1@huawei.com> <20180118150801.714ecc34@bbrezillon> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 Jan 2018 15:08:01 +0100 Boris Brezillon wrote: > On Thu, 18 Jan 2018 14:05:05 +0000 > Wei Yongjun wrote: > > > Fix to return error code -ENOMEM from the kmem_cache_alloc() error > > handling case instead of 0, as done elsewhere in this function. > > I guess you've used a static analysis code to detect this problem, can > you name it in the commit message, and paste the error/warning message > it reported next time you submit this kind of patch. > > > > > Signed-off-by: Wei Yongjun > > NAck. I you read the code you'll see that err is initialized to -ENOMEM > here [1], so these changes are actually not needed. Sorry, just realized I was wrong. It seems that err can be overridden by [2]. So this patch is indeed fixing a real problem. Reviewed-by: Boris Brezillon > > > --- > > drivers/mtd/ubi/wl.c | 8 ++++++-- > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c > > index 77ab49f..2052a64 100644 > > --- a/drivers/mtd/ubi/wl.c > > +++ b/drivers/mtd/ubi/wl.c > > @@ -1617,8 +1617,10 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai) > > cond_resched(); > > > > e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); > > - if (!e) > > + if (!e) { > > + err = -ENOMEM; > > goto out_free; > > + } > > > > e->pnum = aeb->pnum; > > e->ec = aeb->ec; > > @@ -1637,8 +1639,10 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai) > > cond_resched(); > > > > e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); > > - if (!e) > > + if (!e) { > > + err = -ENOMEM; > > goto out_free; > > + } > > > > e->pnum = aeb->pnum; > > e->ec = aeb->ec; > > > > [1]https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/mtd/ubi/wl.c?h=next-20180118#n1596 [2]https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/mtd/ubi/wl.c?h=next-20180118#n1609