From patchwork Tue Oct 2 09:43:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10623319 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 944901515 for ; Tue, 2 Oct 2018 09:45:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89AA1287D4 for ; Tue, 2 Oct 2018 09:45:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75F11287DA; Tue, 2 Oct 2018 09:45:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3D2CE287D4 for ; Tue, 2 Oct 2018 09:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=fqiWlWK/DQpzSFIs3HGse4j966YmK155VKNQdngePE8=; b=uF1Fk2RBAAbjo4 3n84DrAKEAGZrKYY3jKDTygZ+HVqglhzRB/4WsjOAYYWJB7CWRN4knRKuSjNK1KNkTB71K1ZpyjcP y1IxQLkPLhCHNO9e12vJW0yxIXghqslyhUhRPHF8G14E3branusNneNgsw1s+M/E23oodQvC0JBCC 7vr8SeeYxaVsoGyiBo1hq9TtD3Vjt7zKV0hnNwH99uf38xFSsL3hPzFhLAvCGwZwtxSUt/AHtqYqZ MbQj8+XXuttwHqNGHk0Q3Vk117oQYJzfRIt2eDxywswAGuifaFIaOicLcSNo7gKRlPraEkKbU76fD E1UHoZZVKFurFF+uPEwQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7HFB-0001DR-Ub; Tue, 02 Oct 2018 09:45:30 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7HDq-0008Fa-E0 for linux-arm-kernel@lists.infradead.org; Tue, 02 Oct 2018 09:45:10 +0000 Received: by mail-wm1-x343.google.com with SMTP id z204-v6so664868wmc.5 for ; Tue, 02 Oct 2018 02:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GXs1lClEWsn92wLmUxVM+cd4Mz2GfrXa5objbOmjlQo=; b=lxAHv31xmGTTjVY6FrHZRKPP/sDlR97vQxFu1y2Qz6u6dNtqzpiiiDr2WJlOaUqexD wESE7DKPnvHRuDRvdeWuZSoT3RNAFTy8p8T4CUjaXg8YHlWFo7/Ob7DVJF3yYGywJbcR 0M0nMlh45eStYIg+cdAUhCGM53NPrylKqkruAtcTVTDljcX3vMoE+FHKwIXb5SwyYRFE K4oyFHd3xuBGS28tfFn9DYhEkXTX+d8zMPO7c3VpU3bv9Cu1qImJz2VCeHDGBgpAts2+ 2N3TOFLjmI9VpidbNF9AOr7SThR81Gj1WgmUoVWplAlkP6bgHjYsoeJFjREIfSzcKGer oXhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GXs1lClEWsn92wLmUxVM+cd4Mz2GfrXa5objbOmjlQo=; b=kxPESv8mE2sYOHCPe64AnY9jXSd2WxD00TujyCNdQAEPQDhhEFFC2HJt7hx0RMgxcW RXJWlwtF/37jeZRfyTehylaCSgNepmntlqGXFQJymRv4c7AuvobXVFheJTE5hBHWh7pP mqSNczD6PfpTHOR+xyZ96pHisUcnln50b47qS8ivQqZ4+YcNe7RiuWhwx+kRP7HqIxvd 4NaK7O2dBfiExY5ZzAQfyokB8nKh8M6SN+kwf6LUJpZrvrdntnUluJ9E5Nq6X1xnlkeP 4BRYbTOECZK8HkHZ7gvZMWE9+LYZcFVAJndE4675uVlaEsbW3jzaYhc7G34km0ZmUDto Dqkw== X-Gm-Message-State: ABuFfoiEdy2M3IglbkoVySyMZGZpmzIMbsMD5Z9Jsg4i689msfzx7na+ Q+md/4/q1/XTPcIZXYtJxvr9ew== X-Google-Smtp-Source: ACcGV60qbeO24HWoB67EJEmJ4fmH7anTnVPh7li25L6qHDkMMq/HrcN7xEfsAXdsGL9cx2A7jtKQIg== X-Received: by 2002:a1c:c145:: with SMTP id r66-v6mr1254363wmf.131.1538473434443; Tue, 02 Oct 2018 02:43:54 -0700 (PDT) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:217b:7d7b:52aa:bc53]) by smtp.gmail.com with ESMTPSA id r13-v6sm10863996wmf.35.2018.10.02.02.43.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 02:43:53 -0700 (PDT) From: Bartosz Golaszewski To: Srinivas Kandagatla , "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Arnd Bergmann , Jonathan Corbet , Sekhar Nori , Kevin Hilman , David Lechner , Boris Brezillon , Andrew Lunn , Alban Bedel , Maxime Ripard , Chen-Yu Tsai , Dan Carpenter Subject: [PATCH v2] nvmem: fix nvmem_cell_get_from_lookup() Date: Tue, 2 Oct 2018 11:43:50 +0200 Message-Id: <20181002094350.17649-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181002_024406_498365_221FD91B X-CRM114-Status: GOOD ( 16.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- v1 -> v2: - use ERR_CAST() instead of a direct pointer cast 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..f49474e1ad49 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 = ERR_CAST(nvmem); 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; } }