Received: by 10.223.148.5 with SMTP id 5csp7691871wrq; Thu, 18 Jan 2018 08:25:21 -0800 (PST) X-Google-Smtp-Source: ACJfBouKOcgZ007Hc6WqAxAqORODZ5z+vAmph4j2LtK/txatOWEHanfBI+rzwaqw/Z8ZpWgUItXQ X-Received: by 10.98.16.132 with SMTP id 4mr35719737pfq.42.1516292721699; Thu, 18 Jan 2018 08:25:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516292721; cv=none; d=google.com; s=arc-20160816; b=pcSwEYDVzPcPxEOj3WQvn9UX1tirHD+6MgkDgsclubuDR0G2r/LTPJQFBoo2lR8NHl po2EkIwok7kgN7Kd03gSMxOOH7ZZwdk6Qo/LQVKe3KFcbf7loIVWyGJvoSYntSBsNw3s tDYrHTtMmM61n7jfpTQG0S0PnN1/Qyx1sf03ege2Zmpa0CiHa1Rm+iI1ADA9LSGIhI5V C/Elq83fEQdT5V5ibamfMwWf15ZcQ4+/hEuMD1j4Ns0wTer/V3yiGdsDQ7lm4DZGsF4y mBQV6L2gDd99LUrVothjytcUTKp7xNaH9z5lDKVDrFBECOPKAUh830PSHiHYBFifEsCJ AJKQ== 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=nIPFNWePekSUlbwafkmQqEMD5m9dGlutfIjsM+XaP2k=; b=UFVJ66zuyVshoQMPxPNZO2DQQGYKpwgcrzAkB9JFVysYmsBSLfcU7RhbFgmt910eCt +dBc1/6R0amJTBtb1L46Y71E/fBvX3LTFWR3dy5fNayKx7V+rRdQl+qgmUWKE0Oxfocu jXQSffnoYnGk1AABUe/QZAq4FJBcQTr9z0dy1C5l6yz0NOlis4H5U4eJi3G4iRLGBpv1 UrNaBF5zfJAsKPqB7rqqbhLd4u/jspgwhZ+A23/7zZ+qycSZAbMKjkQKxcAdl2qXM18o om206cvbvUfYBlt8f+jsqVE8FDKTLNl6gXABl8GnIe2Nx8Hdrzj970Qk2dvJvl9lV/pV rqcQ== 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 u14si6577185pgo.179.2018.01.18.08.25.07; Thu, 18 Jan 2018 08:25:21 -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 S932444AbeARPe7 (ORCPT + 99 others); Thu, 18 Jan 2018 10:34:59 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:39249 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755881AbeARPe5 (ORCPT ); Thu, 18 Jan 2018 10:34:57 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 552E720922; Thu, 18 Jan 2018 16:34:55 +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 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 F1860208FF; Thu, 18 Jan 2018 16:34:44 +0100 (CET) Date: Thu, 18 Jan 2018 16:34:45 +0100 From: Boris Brezillon To: Wei Yongjun Cc: Artem Bityutskiy , Richard Weinberger , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , linux-mtd@lists.infradead.org, Cyrille Pitchen , Brian Norris , David Woodhouse Subject: Re: [PATCH -next] mtd: ubi: wl: Fix error return code in ubi_wl_init() Message-ID: <20180118163445.5e465f90@bbrezillon> In-Reply-To: <20180118151132.255e0173@bbrezillon> References: <1516284305-82544-1-git-send-email-weiyongjun1@huawei.com> <20180118150801.714ecc34@bbrezillon> <20180118151132.255e0173@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:11:32 +0100 Boris Brezillon wrote: > 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 Oh, and you can add: Fixes: f78e5623f45b ("ubi: fastmap: Erase outdated anchor PEBs during attach") > > > > > > --- > > > 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 > > ______________________________________________________ > Linux MTD discussion mailing list > http://lists.infradead.org/mailman/listinfo/linux-mtd/