Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp554455imu; Wed, 23 Jan 2019 01:14:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN4/o7v8+fmAPIvs25/dzHeKqFDNXbnY6bw4Bn2BH27xw9xwiLIJw60jLzFE2Xy2UguC815c X-Received: by 2002:a63:5518:: with SMTP id j24mr1271158pgb.208.1548234860945; Wed, 23 Jan 2019 01:14:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548234860; cv=none; d=google.com; s=arc-20160816; b=JdpxbS/oMpaBwuRZInID7ug5CWXztJX/R+URxi9vdEXT1zLBbCF/icU8j/tGNNlNTw R+QflQ0DYWfKXRyXBiDQMJuJRBb7Q4wRU5VwIWsWeulQlSJxaGSKp3fcP5rLBDWCBgSk 6MLBHFWLYCHsWAehYczsF1uMB5mcUNfrsvw8l6NdXrGA9MCYEuKDvD3zJ8NTneyFLVzy GfQtkObmRwJQLBHZgKiI6Gav16xUie6yXr48W5td8k9SMb/S2ZlyB+7fcXxxvZt4btkU 87nUxbXbIW+iH+x3N6wrNIvDB9dNWcUfDG6zE6S7DaM9Osubgh7E5akD+/EkX3QfO+f8 Gu3A== 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 :dkim-signature; bh=58amn71Ez0G5PMUALTM6sryUspuTb3K5VsgbrjvFwIA=; b=vkDHUZmuK51UAg+TPkjKAV48Sg5tbmvOYrVCtyaJX1GeCzZreKnz1RJ2kL1PmJxedm T/lUNsh8fyLVRJjrNIDbXq+NUy/xSxnsPo7ZydyWn/ytn0TfupAq+3fesQwrN9gQs4lc Y0gDkaoEKBnZxvCeUjSYTaLY0eLFzwXV1+7El6btVLXkzoHGkTVG0zhh1gSitj4lALL0 CFM2oqpkDRDrI/74gtu+LyiopOWjHCJSmnVnjDg0g7blBwuIB4dIOEZRuDC230FTEkRm wqpQYGiJZM0Q+ag7eihCVjoPBjpBws6vsd/a881qWMZ0qfhr7eubr9sdIwannyv0drX1 phHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0uBVJLYw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si17565102pfe.159.2019.01.23.01.14.05; Wed, 23 Jan 2019 01:14:20 -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; dkim=pass header.i=@kernel.org header.s=default header.b=0uBVJLYw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726373AbfAWJND (ORCPT + 99 others); Wed, 23 Jan 2019 04:13:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:36312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726158AbfAWJNC (ORCPT ); Wed, 23 Jan 2019 04:13:02 -0500 Received: from bbrezillon (unknown [91.160.177.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7301B20870; Wed, 23 Jan 2019 09:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548234781; bh=8Enx+9BncfPCChr/HjRpTG0ZOZvtCrx57UOvXZ5Q7SE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=0uBVJLYwQhM0/DUctNNB5CKB9nZIetZILpcatLt4Q2yhHvkIDi/Ec0ZL/LU53IDsP bDnd0RAFv/2AFYbj6xv8P0aERt+8ojaaWxAIYO6llHKhbdq6uc0PkeyjSn5F5eabV4 B8dYC/cxZVJZBPyZT1/ME9ZLKZyy+XE89uYFOdgI= Date: Wed, 23 Jan 2019 10:12:53 +0100 From: Boris Brezillon To: YueHaibing Cc: , , , , , , Subject: Re: [PATCH -next] mtd: docg3: Fix passing zero to 'PTR_ERR' warning in doc_probe_device Message-ID: <20190123101253.243add9d@bbrezillon> In-Reply-To: <20190123065827.16748-1-yuehaibing@huawei.com> References: <20190123065827.16748-1-yuehaibing@huawei.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; 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 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: --->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; }