Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp229803imm; Mon, 1 Oct 2018 09:04:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV626q4pb6C8tYeJngsbxPbQWkXu95J8DukxRKsYmIga+Ebkw7FL833PiusCti/H9YU0CPtdW X-Received: by 2002:a63:7d43:: with SMTP id m3-v6mr10809692pgn.341.1538409865042; Mon, 01 Oct 2018 09:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538409865; cv=none; d=google.com; s=arc-20160816; b=gF1s/RjsvECdj+bAZjDTCxz8D2ZN7dkIRaqd38tueTa3phIKvefAmVSGV+tY941sin D/PW+w8GwNN2bO9J95ld7OFFbQrmMcXz7USzf7KU/BdxUFoTHuHT2cJAYQiRm8VOnZJ1 omsEWL7pQXMqEo57nCb31MvpvwVE+yARjqr4AyIRIY0BxlOjrCeKVdJj2Iq5PbYLtYNx JxQI9wxXF1RskgQm/1TolhMZ+mIFqlqoZW4F33kujcCKnvEkCsA0c89K4Q1IUPusKoHe WY3xcjzWBvBhzYrnjg9Uvjz83Vcirlx1ITrUpId+Z0bwtrkojYrNIcUAHdRDxG3mkHWc V+ag== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=UWbcjZtkouA+yL6TDCKP8xSGHrLyA/Qwy8Xm9cxg3RI=; b=nf9SJTp/S9Dd/p8prvaWgQ5zVZCbQVpoJ6FRf6+SsIpkRPEaABuyQmT6SxjWFUNQ2u WJjmSvQc+x0EfBT6dZg0yeF14LOYzRHkBGHFb3syPAYCSyOk15pm3SPzz1yHE3wCCsAZ SxQQBhHsy8nvuSTlY+yHEymO4xDOKZ7ATTDmZIE43W4/IYOcvhzKXnETBUYtf2a4z2RL VxE7fbUoxJpnRwEnVVoM/iAz2cZRo5rY9rgcsqyGWe/ROtYvJMSU5pZS/XLtcJirsNc8 YWrDaKCCg9DmiaMhAFGIb8l98uVscJvcmdGg+utTObLxSnpnZGW2QA+98AqDqk0MM1V3 p6Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=FfkiVAZE; 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 o7-v6si430026pgp.631.2018.10.01.09.04.10; Mon, 01 Oct 2018 09:04:25 -0700 (PDT) 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=fail header.i=@lechnology.com header.s=default header.b=FfkiVAZE; 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 S1726233AbeJAWmZ (ORCPT + 99 others); Mon, 1 Oct 2018 18:42:25 -0400 Received: from vern.gendns.com ([206.190.152.46]:55959 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725735AbeJAWmZ (ORCPT ); Mon, 1 Oct 2018 18:42:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=UWbcjZtkouA+yL6TDCKP8xSGHrLyA/Qwy8Xm9cxg3RI=; b=FfkiVAZE7Clxt9Yt/BFfyp9w0q D3P83SCamLS70n56a3rjJreFMzYZY11JRd9rXzLA0RdFuG5JzFTXnhlEhW382iPjMZO2RCCNKqHyR KOduhjfHyaskKlYgzNSBWvXj4rVdHN0abm2zOggvEpMCbjVJXnmohCuJP2E87WuEyphkbX7cVYe8w LdmzTw12aX68mKeIxzgFb6qzyqfRb5nFhaI+8wc5F+crgl2YNsd2rgZ7LffxoplDOruoZXh/leP19 8c8/zZxWoAnP4mMmKu00g/YAiciRBiP8+2lPLj/WAo802UCYpiaANPdyRYXRaC1LZ+p0el5p59Yl1 BMpoL3Ig==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:60196 helo=[192.168.0.134]) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1g70fm-001lmQ-38; Mon, 01 Oct 2018 12:03:50 -0400 Subject: Re: [PATCH] nvmem: fix nvmem_cell_get_from_lookup() To: Bartosz Golaszewski , Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai , Dan Carpenter Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski References: <20181001100052.3580-1-brgl@bgdev.pl> From: David Lechner Message-ID: <44adbace-6849-e37f-70f0-d11661e6bdc9@lechnology.com> Date: Mon, 1 Oct 2018 11:03:47 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181001100052.3580-1-brgl@bgdev.pl> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/01/2018 05:00 AM, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > We check if the pointer returned by __nvmem_device_get() is not NULL > while we should actually check if it is not IS_ERR(nvmem). Fix it. > > While we're at it: fix the next error path where we should assign an > error value to cell before returning. > > Signed-off-by: Bartosz Golaszewski > --- > drivers/nvmem/core.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index ad1227df1984..8249621d11a6 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -952,9 +952,9 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id) > (strcmp(lookup->con_id, con_id) == 0)) { > /* This is the right entry. */ > nvmem = __nvmem_device_get(NULL, lookup->nvmem_name); > - if (!nvmem) { > + if (IS_ERR(nvmem)) { > /* Provider may not be registered yet. */ > - cell = ERR_PTR(-EPROBE_DEFER); > + cell = (struct nvmem_cell *)nvmem; perhaps ERR_CAST() would better indicate the intent here? > goto out; > } > > @@ -962,6 +962,7 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id) > lookup->cell_name); > if (!cell) { > __nvmem_device_put(nvmem); > + cell = ERR_PTR(-ENOENT); > goto out; > } > } >