Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp239018imm; Mon, 1 Oct 2018 09:11:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV62tAyZ2oAjEG2mYxbfvRfMni1blW73mv7OJ9O2k0U+NVv1A/UIIa6CbZ0x4u3Jb28BQw1Eh X-Received: by 2002:a65:65c6:: with SMTP id y6-v6mr10654844pgv.233.1538410295978; Mon, 01 Oct 2018 09:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538410295; cv=none; d=google.com; s=arc-20160816; b=i5Vdlsrf9DVjNHla7i7NWD2lx0HTQvfTDn4pV8MYy2CQIwrl58y4urQEHe57ZHFUWA l0KVhW7Ztm5LVaFhH5BxdD261Tt3JyOJAugQBdIXpoJWBk+GK7tfIitK1YuHFSZMC5Rq VbxJKeWY7gW1xEzDRaYPS68v54c8gSNDvZHNk/6+E2V/lHFBlwe4Lnx1iK6ycrhNNc4p zqVOtj4MkHfzm5icFk4Z4PyfaP/YvzdWqkCtCF1yg0jaUWINudbNdxKIRApj5M4iAtNk mhPdHiBrzJxHS/zD31nKtXfx980CmTEtWQGziLLbUrl+czPviZDfzml9ANEljW4KPAJa +D3g== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=28ikbkritnwd0X0sDqtZ2GOJdZgiK1O30ZJZmBmHzCo=; b=A3wbzWFJkwZBKWbWUytnph1yzKcCy7ENZ7tvAXE3nyR2lCaGLwX18IygWW7HjpnUWT 8BHF+YayzNP8J/CTig/A6PjlCt1F7pY3plRFe/AECL99Wz88jifG6cNCnFxfN3k0S4nl HWWjUtiEbDGw3ZyxzJ30tMMIipFe+JAme1+qGS//GTNXp/8WdTkTWHHf1iLnlS3uLlQl S8/+mLWppzOUX21mqOemWx/s7lL8I5q2vmzG5sFswXm6kQFacntsyNJLNXG2Wgp0Uz+L zBxClKznE6oc95Cu8EKN9MMgltPXTB1ruYYEfYZTMEKjBuXOJrg+yz0Wu/njnd4AsVI6 L1TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=DvsbQFq4; 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 w5-v6si12415536plz.175.2018.10.01.09.11.18; Mon, 01 Oct 2018 09:11:35 -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=DvsbQFq4; 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 S1726207AbeJAWt3 (ORCPT + 99 others); Mon, 1 Oct 2018 18:49:29 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:40260 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725777AbeJAWt3 (ORCPT ); Mon, 1 Oct 2018 18:49:29 -0400 Received: by mail-io1-f68.google.com with SMTP id w16-v6so9864040iom.7 for ; Mon, 01 Oct 2018 09:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=28ikbkritnwd0X0sDqtZ2GOJdZgiK1O30ZJZmBmHzCo=; b=DvsbQFq4WR1P4zaro854x10NWgaBW5qdCo8GMmb4N/MpacWUkcG3COITmoSgjnDJEc m3ArTfRMiSfsekJe2b5+cO54s3UeVq3qEiV1wwjf2ELOd1F76i+/YoDIiT+l2eDPkIbz asrPdZ3vsw6som3MzmmDWC9Hrc8Qy7ZJ+frttWUTs/HHlXOZo6e1/DEFoSaD9Fx3esb4 CTOt878RQkPHbujaq5+S9zfdB0wV/3dBH/qLr9oeyGwdzd2sZdeQkjkNfJWZ2LPzKOc5 cKlU+N/zDI7TWk+cVRQOYGg147k4ukkUgTrkBpYHAXDBiPDLsXBgFANA2gxrEdH8Mn5+ fpUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=28ikbkritnwd0X0sDqtZ2GOJdZgiK1O30ZJZmBmHzCo=; b=Nh8CokNwfHv27Pl9E8rwBgOV+ChydGVRbubkQe2ZkYlAng4kHMPhVF0C5vMcpB+B/Y 16k/9TVu8kg7bdml8xBwWr4+t84GVjAyXCt/DbfSBxqgHKn0T5/3sGWaNyaWw/ILTBVV YCI3FF+DKYaZ3CvfBZT1QubUudzyxdFMqZgqcTXkQBpPKZK+bNIHTfxywpVGxqLO4wHv mJ6TdKV0SPDw2sy0KmGrA93GmjpElNPruE46tWYmH6YzxfZjRY7FOjkDapDcpTUiBBfi aNieRZv/eB/6BME5z50jn3Hs+6m7SvPiFXlMF9UMjy/y21WyDBfzHAu2V6YzOlGcFeac qBsA== X-Gm-Message-State: ABuFfoi2Az/rzbHIz6Mjp9lzOdVW0iIdfB/v9BN694Ss0BSzy3ciC10E RuVF+dijvSTU8nymIxelAKls7YqNqxVOf51qDSnwZw== X-Received: by 2002:a5e:8d11:: with SMTP id m17-v6mr4019218ioj.258.1538410257133; Mon, 01 Oct 2018 09:10:57 -0700 (PDT) MIME-Version: 1.0 References: <20181001100052.3580-1-brgl@bgdev.pl> <44adbace-6849-e37f-70f0-d11661e6bdc9@lechnology.com> In-Reply-To: <44adbace-6849-e37f-70f0-d11661e6bdc9@lechnology.com> From: Bartosz Golaszewski Date: Mon, 1 Oct 2018 18:10:45 +0200 Message-ID: Subject: Re: [PATCH] nvmem: fix nvmem_cell_get_from_lookup() To: David Lechner Cc: 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 , linux-doc , Linux Kernel Mailing List , Linux ARM , Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pon., 1 pa=C5=BA 2018 o 18:03 David Lechner napisa= =C5=82(a): > > 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, cons= t char *con_id) > > (strcmp(lookup->con_id, con_id) =3D=3D 0)) { > > /* This is the right entry. */ > > nvmem =3D __nvmem_device_get(NULL, lookup->nvmem_= name); > > - if (!nvmem) { > > + if (IS_ERR(nvmem)) { > > /* Provider may not be registered yet. */ > > - cell =3D ERR_PTR(-EPROBE_DEFER); > > + cell =3D (struct nvmem_cell *)nvmem; > > perhaps ERR_CAST() would better indicate the intent here? > Wow so that exists too... Thanks, I'll resend tomorrow. Bart > > goto out; > > } > > > > @@ -962,6 +962,7 @@ nvmem_cell_get_from_lookup(struct device *dev, cons= t char *con_id) > > lookup->cell_name)= ; > > if (!cell) { > > __nvmem_device_put(nvmem); > > + cell =3D ERR_PTR(-ENOENT); > > goto out; > > } > > } > > >