Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3696919imm; Mon, 1 Oct 2018 03:01:47 -0700 (PDT) X-Google-Smtp-Source: ACcGV608/Q7KTcWN9r0SN3YK+Rd7L8Czw6DngCGt1nAcjjjezovepugqx+j7WWz7k+ASRl93zwIb X-Received: by 2002:a62:86c6:: with SMTP id x189-v6mr10722183pfd.252.1538388106939; Mon, 01 Oct 2018 03:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538388106; cv=none; d=google.com; s=arc-20160816; b=E7OzJJIo0gPCakgoGwN/CsATkoDZPU2n+q7VcbiUiapC084SxwvQCJrnRrskPTXabL Y1PDQ60XPeUpvE29cy1lktSwXzWSS16AjcFmnua8t5pPegc/bZ7C4jvz5AZh801vL4d7 tO3KWHQxxkr2oPq3Y2Z+IU7gFLTiFnfSNWDMqEcS/UJPNMDsI41qW2WlQucWFbThUaEJ Hs0xFCaGLhlkXeM+tlaNCnSG8nVntlYOU2HUr7VWKxewVvadgtipPt4aNWj8V6UWSr/C 9pYpFd8ZhYiHZ8klHoeUvlJs+6xCuYZUeX/T86hOtM+tEFVJu8WXkMmbB2VTm16t4Hhe k8fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=9lkGVsNxlX+MgxZEditI3+TUfrnT+qVHsgFgcxCtk2w=; b=WVNfcNjLVchR9VddUZiunyMgHwwBYiki1baym6ZaHr04NNy6+KfiDj5k++TDgBpFCV xarJ48mM/F5gkpl7SOY9mXPgUC3GcXt04CSM8cC3h/kOdCgksMbzVipP6s53x4JbtY3B XSFZ92si57LRdn0aKBcTIsHxfwT0ldCMUPjMPo8c07+5N7sygEELsPUbgs+kJwAoy0aQ XVDdA103NwXX2YH7lZGXLTLE8J3NdswqmTzs4aKSeo3FpewVL2ddyHcJ8WhfYLRrpVlb Buxg4UNfY4C7cEYsxxYj5qySpmhZbBIxYwqgXHztnPywWrdkWoDxZ+6vXEPMl/WjUgJT cyOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=ZOKxpbUW; 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 b3-v6si12799569pld.36.2018.10.01.03.01.32; Mon, 01 Oct 2018 03:01:46 -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=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=ZOKxpbUW; 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 S1729112AbeJAQiK (ORCPT + 99 others); Mon, 1 Oct 2018 12:38:10 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39070 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728960AbeJAQiK (ORCPT ); Mon, 1 Oct 2018 12:38:10 -0400 Received: by mail-wr1-f66.google.com with SMTP id s14-v6so13197012wrw.6 for ; Mon, 01 Oct 2018 03:01:09 -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; bh=9lkGVsNxlX+MgxZEditI3+TUfrnT+qVHsgFgcxCtk2w=; b=ZOKxpbUWqhLgCP4ASCtZf2YdLW4a+l14c4un/aoCYcSJuR9rsb0UNquKVmmrCGxFL6 3oWXytaXh0svUcJRIip6X1jLt0ZKg0nOi+SCuRycOQIGElbTDThaYd9iW3YQF6w0JNH/ CYiUpf7SkH3AFJgNYdKGa3BTqTApAu8rG/VojZKdy/8vIWsuiZsH9UJx0TnzyXjt6asm JbOHcYOuYDOTXU6C3n8tIACaYWNnJ37ors22VHql+VPrik4mFxQBQWVpHvPSaMB+vHuX sWEcCnomajArBB7M3yuh0fGJa2tW1LyG2juGzwMsu3s3jQeFIQOvYKElQ8r6whEs9/jO +Mpw== 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; bh=9lkGVsNxlX+MgxZEditI3+TUfrnT+qVHsgFgcxCtk2w=; b=V0hf7sGB0RfTuYKxD2Z7zFnN8IuCtZjA7TMJJy+JeLDVjIBW9BAco53Jfdu+uDSpTX eAwFrSn3vAEg8ilUiJYUHIF2ttGsmXSvHbUPikrABoL0ox4HXvlPBCZoG9TQXqAKNVDT w2wY0Gvsb/1SS+K3iyYuaDi96TwU11YQ1e3IdBipboGvXfNoaP6g6BcucbnBbuuW4Cya 9KygaDrbjATlNRitB/9tM6v/OBa8kD3nkimylVtRGWHomyWxo2E5fKlTh1jbqxIZgdnh sIfT03q7r90Y5OKyqIo+boKdPyDjVYjVh4m7dZkMEcru7SrKiMJwfCHyNbOTR4GVYRSF ME+Q== X-Gm-Message-State: ABuFfoik2fMTw9dwN9PUExI2x+Kf9mYytEL3f5sJCe3P12fmJnSuOYHs xV3IRECT8iQyLoA4LCWltZljeg== X-Received: by 2002:a05:6000:12c5:: with SMTP id l5mr5239511wrx.215.1538388068551; Mon, 01 Oct 2018 03:01:08 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-14-252.w90-86.abo.wanadoo.fr. [90.86.135.252]) by smtp.gmail.com with ESMTPSA id c13-v6sm1537658wrm.50.2018.10.01.03.01.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Oct 2018 03:01:07 -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 Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski Subject: [PATCH] nvmem: fix nvmem_cell_get_from_lookup() Date: Mon, 1 Oct 2018 12:00:52 +0200 Message-Id: <20181001100052.3580-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; 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; } } -- 2.18.0