Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp579358imu; Wed, 23 Jan 2019 01:46:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN7qKai+Co8re+DoYJC3R16l4ghAgatuyb6Fgm32LqEL5bK9ZfK+7CLX11EMoTIhOSWsPv07 X-Received: by 2002:a17:902:7107:: with SMTP id a7mr1541521pll.290.1548236798468; Wed, 23 Jan 2019 01:46:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548236798; cv=none; d=google.com; s=arc-20160816; b=w4n7+WJ/BV/XnyRea+cGXob9fLfHBVlwiYXdIGQe8jDM6rpptWeIx11bmSkD96B3z8 1BgsAQkYIYCHQbcPQmSk09kMJW7BZ1mBO/G67/aZdAdB7QL9qq31NtG89DIsh7eiOVyL J5L/c7LrZtPO7Q3fOhfiiMtBPw2OSULUIrItkZwzTt/0BvyCWLLC3kxfSn4uScWEzJ6F U4QrWgaLQ8q5x6KAbWV/f5072o2iw3RCHAjPa90pGx1SrEwRf3+xBEO4VizO/KJvupMC 224N2bFPFeK7hLKzPWTikaOeClddy0YOjLdfDkAwslvn4W/yrkVhwUOTP908IxkM07c4 mdRA== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=Aq0LyKNv7BZ3yKhndwCq+sxLLOD+Fom5qRCgTyMXPPI=; b=zsfxnO5H2qKGvYn9a+3D8VCWLaTZ88HdYB4+CjkcZr60fti//ZDMrb5wq13V19jhwz ahRzzvf2IRwXiPJcKiTdvpM63fGGEJ5i6z7EWCJzPY/zjpD9pLjUMQT8DZGSDbR3aBIL 6E0dn4xsoHG8ojPWGSDUeuhrtMbGEc3VnZfdGIgefjGpprKfiOzXJpuSlbPfZJaNdoU5 DIofES4Ju859vQsSFYhwaqVhj/5FYWWUL/fh8A1pxl6qc89Zn4GXWj1uabGZ/wqYdVIt APgzz+ugW/ShHQBE5z+zIMBt4Se7o2LX1xlMuv1W6qBevoZddxPGK4TZW8ySv3dpYu/B WXdw== 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 33si19528125plh.245.2019.01.23.01.46.22; Wed, 23 Jan 2019 01:46:38 -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 S1727200AbfAWJoH (ORCPT + 99 others); Wed, 23 Jan 2019 04:44:07 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:46882 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726804AbfAWJoH (ORCPT ); Wed, 23 Jan 2019 04:44:07 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 06CF6FDCA6B3A4A995E3; Wed, 23 Jan 2019 17:44:05 +0800 (CST) Received: from [127.0.0.1] (10.177.31.96) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.408.0; Wed, 23 Jan 2019 17:43:59 +0800 Subject: Re: [PATCH -next] mtd: docg3: Fix passing zero to 'PTR_ERR' warning in doc_probe_device To: Boris Brezillon References: <20190123065827.16748-1-yuehaibing@huawei.com> <20190123101253.243add9d@bbrezillon> CC: , , , , , , From: YueHaibing Message-ID: <86533285-e800-5cc0-f495-88fff8326b5a@huawei.com> Date: Wed, 23 Jan 2019 17:43:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20190123101253.243add9d@bbrezillon> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.31.96] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/1/23 17:12, Boris Brezillon wrote: > On Wed, 23 Jan 2019 14:58:27 +0800 > YueHaibing wrote: > >> Fix a static code checker warning: >> drivers/mtd/devices/docg3.c:1875 >> doc_probe_device() warn: passing zero to 'ERR_PTR' >> >> Fixes: ae9d4934b2d7 ("mtd: docg3: add multiple floor support") >> Signed-off-by: YueHaibing >> --- >> drivers/mtd/devices/docg3.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c >> index 4c94fc0..60ddc38 100644 >> --- a/drivers/mtd/devices/docg3.c >> +++ b/drivers/mtd/devices/docg3.c >> @@ -1872,7 +1872,7 @@ doc_probe_device(struct docg3_cascade *cascade, int floor, struct device *dev) >> nomem2: >> kfree(docg3); >> nomem1: >> - return ERR_PTR(ret); >> + return ret ? ERR_PTR(ret) : NULL; >> } >> > > This is not the right fix, you should instead set ret to -EINVAL: Thanks , will fix it in v2. And seems doc_probe_device cannot return NULL. The NULL check of doc_probe_device in docg3_probe also can been removed, right? > > --->8--- > diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c > index 4c94fc096696..6b84db411232 100644 > --- a/drivers/mtd/devices/docg3.c > +++ b/drivers/mtd/devices/docg3.c > @@ -1842,7 +1842,7 @@ doc_probe_device(struct docg3_cascade *cascade, int floor, struct device *dev) > chip_id = doc_register_readw(docg3, DOC_CHIPID); > chip_id_inv = doc_register_readw(docg3, DOC_CHIPID_INV); > > - ret = 0; > + ret = -ENOMEM; > if (chip_id != (u16)(~chip_id_inv)) { > goto nomem4; > } > > . >