From patchwork Tue Oct 2 09:42:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10623315 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 7843B1515 for ; Tue, 2 Oct 2018 09:43:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D1FF287D5 for ; Tue, 2 Oct 2018 09:43:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60E70287DC; Tue, 2 Oct 2018 09:43:57 +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 15BF9287D5 for ; Tue, 2 Oct 2018 09:43:57 +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=iq6R2PttAiFOUCuB9p7lVw6kcN8cBz74vI+TNbt6afY=; b=d+99OG4kvXGJKG HuhDOA58yXx/Lt4DkY/Dz+9ECy1cNsCWOaMM/83JyUccnmFpWx7kHWMKjuS7E4ThcdqXtpHCji/45 GO9Q8HvyInj+H221iHrWn98zgpiUrNd+NSadzW+g4F3VtDJ8RW5vCOMBrlYHQz5D2tornte9+iBSJ nSc3H7DhxLLSA+Taqe78dabIlWB8S0wcVWu7BjiNZL8GbQqSBwgZ6LIp3tiEhYElLITg0v8jOClGa 0uQvQLuQVVFpJOjUNXwuXHaKsuesPntMvO4jkGv5TiVEnMBHFZLerxRMlLUl9yFy/fezLdPr1CS40 T37yx1d9Hk9bnyVV+iyw==; 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 1g7HDV-000893-UT; Tue, 02 Oct 2018 09:43:45 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7HCh-0007ib-F3 for linux-arm-kernel@lists.infradead.org; Tue, 02 Oct 2018 09:43:34 +0000 Received: by mail-wr1-x441.google.com with SMTP id z4-v6so1411662wrb.1 for ; Tue, 02 Oct 2018 02:42:45 -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=V3jZM2zRxZov3RiYJJND5l9o9GvRdVPeg8Domw0sixQ=; b=rdv7BvnHz8eN8fvqCehuj2i61008VQhDgwsFte0rmXuwF4XjOBndwGkgD915PwUulq Py+qaQbXLcBFT1H8ujLvfpIGCjq91U5NvKmDIjKy6YNCyT1eZtCbVp5cGw7OiClk/SSh 42JhDXElxUZ9RfMGFi4gEc1p5l1rCT1heo3eEH4Dr7y5nMOIuzfp+R1vi41Kcmh7tzsL yIFrWWFmV5SWhEV9FF1yZA3irU2gYJhOe1R3IJE8EAhkGN5qc+AxvbxoxmruGoktgrNm ChVdvOX3eu5ka3qfMC6xTV4cYHmVUJl7g/1LoozLCnwGac7RR1ISwQyPWHHX8MOqjucP YbeA== 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=V3jZM2zRxZov3RiYJJND5l9o9GvRdVPeg8Domw0sixQ=; b=tgMX2jE27Q9CqHFIFxQJC6ALMtqrOJLlLUrqM7O6SjMi1T5JBdPatqPTQa++0r9Vnd 1QJwk+3r+RnRv4qpWLJijM5E+MxkJit6xQvDZ/VAl9nXpHOE+LkDFTZgELm3zRH2rQ2b qjoNIGdO7UsufiDvOPm5Ju4AkQAeGmF0RmsnE7Ac6EcxL8YjlS6ZVPzQZ/rtcPyIBd0f RAizAI7NOowfIIu27fMgLJ4vlpUU2ke51IscvVJMuboRtCtxDe0kIi/iWz+ChaqSIsoC QPNjZeErMBL0l31NjvnnGfklF4DamnuIXFvcUuhujKvLZIROru3oUed5An9RfSh+fQ2d pwig== X-Gm-Message-State: ABuFfojw0D4OBaIUy66zHTzk9ikKsLYyS1TCTwvKuHnTlUz78+z0rv6U NE5uo6wjB0+wXTZ5WO0/CsKo+A== X-Google-Smtp-Source: ACcGV62jIN8Ly1/AfBCWyCVlRXJsTUr0dIBMhUhhs65Yxv+Rpg09qePIuNNWr7cCxX4A0Kr6HQ0oOw== X-Received: by 2002:adf:dcc7:: with SMTP id x7-v6mr6148953wrm.21.1538473362270; Tue, 02 Oct 2018 02:42:42 -0700 (PDT) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:217b:7d7b:52aa:bc53]) by smtp.gmail.com with ESMTPSA id t24-v6sm4036840wra.5.2018.10.02.02.42.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 02:42:41 -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] nvmem: fix nvmem_cell_get_from_lookup() Date: Tue, 2 Oct 2018 11:42:38 +0200 Message-Id: <20181002094238.17571-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_024255_525799_DDADD9F7 X-CRM114-Status: GOOD ( 15.88 ) 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 --- 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; } }