From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796071250; b=1Ov25PecYEPjH6nArqeJf7Bzx5AD9cFWwdpvTH2SZXcCpl83IX/fDy5vKkrzaqhQWwR4 t5/JccViRTmy0kcff0knQrVKfBzEEzp53PaeSkCFABsVHToDZLmmn0aH4dH5mYr7bUgbo ifr8o2A3WmOnvji/JkWrq7QgB244eQpsiKYsFZGfVg6JTDDJJsNzj625kOVtSKXNF4kwR xbe+sTRqbgrenrU9zItOKL8zHKddN67AVO1fCwclIeWoZlGa/dQ2W/sVRu5j7EKrcf87k Av9CIXXhHZ/FidfMHwiWUUH+tD+OFdDvqv+UdkgvKR8wnfWcxsQ13FqHa5deL1hhVZg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796071250; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=RzRDyiKOB+pF/hyd8heLQW+SJtkw/CBe7cT/ZfyvgRQ=; b=zpPYYVsBQt6aB/b7uY/yya5wUEHwyZCTriXDzzNP8/9ZmSH7YUb9xd4g8Fq3VcwMvpyx 3vkpdY3wHm31/u1p076iFAHsrPb3YYO0itlipOCqRguzYef/bwWDjiYi3EeGIBrmM7lXJ AyazpGOmxc7PRaPMGskMLUQFbtkB5JrOAtLJiIw2sdBW7ASJxibA62j0uTlAVLfMFNB02 3/VOxZVQ8rIJUxtcqV0mnB/zeKvGjEDnxW915lVauLotKRjArsntgL9TLLuYPTvebyqtx DdNkPt+trVIgeDn9KigEhbL20Ju0xkx9SZl2SUY8hXiuMefCHwNLcoZHyaTNxshtdMg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ejayQMUC; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71A65606A31A; Mon, 30 Nov 2026 20:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ejayQMUC Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99E6D1F00899; Mon, 30 Nov 2026 20:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796071249; bh=RzRDyiKOB+pF/hyd8heLQW+SJtkw/CBe7cT/ZfyvgRQ=; h=Date:From:To:Cc:Subject:In-Reply-To; b=ejayQMUC4vLKDeTqOYy3BeyvyAztUVgBl7DPs1NYdREoI0p02URTxHx+oVqtOOR65 ihFj/iUcX56hYYVpGyUny398gOL6wrSZLwSbaIR7UHrrnUFFdOd13tcY7HSX6ZuRdI VIbFz/vw84f8oD/h6bFx1YLH41G4qQsOCPnBs1mXLHrj84rAhLdrpOhgiQam+I3Dpx CMoPb+Tk60u0mV1yyBFSCWGcArRLwRWSPYjeHPineB9gx3MrBFPaTAVn5uxc+tzANC 2SThG5joVlPeqiMJC6sq4k4BoQBxylca9KU0E4hFKwdxZH7b5jhzMTOWaDRmdLQfzT 2zr6Upwz+68BA== Date: Mon, 30 Nov 2026 14:40:48 -0600 From: Bjorn Helgaas To: Anton Protopopov Cc: Vignesh Raghavendra , Siddharth Vadapalli , Manivannan Sadhasivam , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Lorenzo Pieralisi , Bjorn Helgaas , Rob Herring , Aksh Garg , linux-pci@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Simon Glass , Ye Zhang , Jonathan =?utf-8?Q?Neusch=C3=A4fer?= Subject: Re: [PATCH] PCI: j721e: Properly check the error of a syscon lookup Message-ID: <20261130204048.GA368348@bhelgaas> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: [+cc Jonathan for wpcm_fiu_probe()] On Mon, Nov 30, 2026 at 09:34:00PM +0100, Anton Protopopov wrote: > On Mon, Nov 30, 2026 at 8:59 PM Bjorn Helgaas wrote: > > > > [+cc Simon, Ye for possible similar problems in pinctrl-rockchip.c] > > > > On Fri, Nov 27, 2026 at 10:19:13AM +0000, Anton Protopopov wrote: > > > The syscon_regmap_lookup_by_phandle_optional() function returns NULL > > > only when the property is missing (-ENODEV). On other errors it returns > > > an error pointer. The j721e_pcie_ctrl_init() function checks only for > > > NULL and passes an error pointer to j721e_enable_acspcie_refclk(), > > > which uses it as a regmap. Propagate the error instead. > > > > "Properly" in the subject is a noise word that takes up space without > > adding much value. > > Yes, thanks, not needed. > > > IIUC this avoids issues like a kernel oops when using an error pointer > > (-EINVAL, etc) as a regmap pointer. > > I will add this to the commit description. > > > There are only five callers of syscon_regmap_lookup_by_phandle_optional() > > in the tree. wpcm_fiu_probe() looks right > > Actually, I think it also stores an error and later dereferences it in > similar way. Probably should be something like > > fiu->shm_regmap = > syscon_regmap_lookup_by_phandle_optional(dev->of_node, "nuvoton,shm"); > + if (IS_ERR(fiu->shm_regmap)) > + return dev_err_probe(dev, PTR_ERR(fiu->shm_regmap), > + "Failed to look up the SHM syscon\n"); Yeah, you're right. wpcm_fiu at least checks fiu->shm_regmap for NULL before using it, but obviously the error pointers are non-NULL, so checking for NULL isn't enough. > > and you're fixing this one. > > > > The other three are in drivers/pinctrl/pinctrl-rockchip.c, which looks > > kind of suspicious, or at least too complicated to verify at a glance. > > Yes, 2 of 3 look buggy. Should I send fixes for all of them? Somebody should :) > > These were added by: > > > > 63113d4fce6c ("pinctrl: rockchip: Add RV1106 pinctrl support") > > dbd2317d7b9f ("pinctrl: rockchip: Add rk3506 pinctrl support") > > > > > Fixes: 82c4be4168e2 ("PCI: j721e: Enable ACSPCIE Refclk if "ti,syscon-acspcie-proxy-ctrl" exists") > > > Signed-off-by: Anton Protopopov > > > --- > > > > > > (Accidentally bumped into this while working on BPF stuff.) > > > > > > drivers/pci/controller/cadence/pci-j721e.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c > > > index 822602836b12..fdae51e368e0 100644 > > > --- a/drivers/pci/controller/cadence/pci-j721e.c > > > +++ b/drivers/pci/controller/cadence/pci-j721e.c > > > @@ -334,6 +334,8 @@ static int j721e_pcie_ctrl_init(struct j721e_pcie *pcie) > > > "ti,syscon-acspcie-proxy-ctrl"); > > > if (!syscon) > > > return 0; > > > + if (IS_ERR(syscon)) > > > + return PTR_ERR(syscon); > > > > > > return j721e_enable_acspcie_refclk(pcie, syscon); > > > }