Received: by 10.223.148.5 with SMTP id 5csp7487439wrq; Thu, 18 Jan 2018 06:09:57 -0800 (PST) X-Google-Smtp-Source: ACJfBourSrvy9C+R7tIX6USzo3fB0FN45z5zgeklkuqMmqPxOluOtPYZsnCefveaFfYGwAgSap49 X-Received: by 10.98.15.203 with SMTP id 72mr42591254pfp.104.1516284597427; Thu, 18 Jan 2018 06:09:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516284597; cv=none; d=google.com; s=arc-20160816; b=yiHOZyrtycKVg63wN6iSaRT1UZiXSaQwSmAwMMBUbXkSfJK+XSNETtUQlgEEF0WuHJ CFWOqMLRJLdx5Kpmq0XYTfIC18GZB+4/Ub3Qd4sF5fu+6lrTiUB+RXv2pbuma13IFVbs QRrHGNPNZIZyVOaJ7Sr4gvSoCL7+ULDKcsA/ADLkcLPx/08Ybca9enSngnACVv2b/pR6 xdJA9v+85YLTWRLgNBOuxKr7OkJM7JeHWzkRgoQ/Ou/8o2Th3uMhpE8JR3TtJWCggAPh wFQzZdkDsATCDDmGr8+VXa78eX6iCnjEAodomodEjkaoD9x2N/fLRpzkVkerJn3Tmfl4 JCrQ== 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=7k79Wm9KVz+SuzGtjjOi3EX7kx/lI4hQpxX4FCn6gHw=; b=ndd6u1fBxcLJ2zzTvk9weBj4TLRmnkeShe42U+ot3sm8vEWSadTElKZjz1okqFXyDm azT0WXWCmhxSs/SDtgEllAFoGMiIys6AsVfyWrnm1MdNMX2EhwGJ1Y8i9ec0aOyQ3qy+ f5OKDfXYKhGXw0pogHQLgRlcmXOVaj84OIdDAd4AffENoII4t+0yYrk86MI7KbHLWBJU 8PAlErC6Xyzl+KmpJTG5iSwOoKUU/XCE6/zb9g6wYIMeuD4Z8dLJgnkCy80eMVo+CPwZ 1IUEE7PD3qAfywK8lfX7t0FjVIACCTMEkgAZO74UvY7gJ+hr1nj/bI5nVYh6HDaMOdXX C7qw== 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 z188si6855065pfz.66.2018.01.18.06.09.43; Thu, 18 Jan 2018 06:09:57 -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 S932570AbeAROIE (ORCPT + 99 others); Thu, 18 Jan 2018 09:08:04 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:35822 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756452AbeAROID (ORCPT ); Thu, 18 Jan 2018 09:08:03 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 15558208FF; Thu, 18 Jan 2018 15:08:01 +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 C497F208F1; Thu, 18 Jan 2018 15:08:00 +0100 (CET) Date: Thu, 18 Jan 2018 15:08:01 +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: <20180118150801.714ecc34@bbrezillon> In-Reply-To: <1516284305-82544-1-git-send-email-weiyongjun1@huawei.com> References: <1516284305-82544-1-git-send-email-weiyongjun1@huawei.com> 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 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. > --- > 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