mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Maud Spierings <maudspierings@gocontroll.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	Stefan Riedmueller <s.riedmueller@phytec.de>,
	Jacopo Mondi <jacopo@jmondi.org>,
	Christian Hemp <c.hemp@phytec.de>,
	Guoniu Zhou <guoniu.zhou@nxp.com>,
	Dong Aisheng <aisheng.dong@nxp.com>,
	linux-media@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: nxp: imx8-isi: Check whether pad is non-NULL before access
Date: Wed, 20 Aug 2025 17:14:39 +0300	[thread overview]
Message-ID: <20250820141439.GA10547@pendragon.ideasonboard.com> (raw)
In-Reply-To: <a9283349-c58d-47e6-ac33-77b5a6b893fe@gocontroll.com>

On Wed, Aug 20, 2025 at 04:07:55PM +0200, Maud Spierings wrote:
> On 8/20/25 16:01, Laurent Pinchart wrote:
> > On Mon, Aug 18, 2025 at 02:31:43PM +0200, Maud Spierings via B4 Relay wrote:
> >> From: Maud Spierings <maudspierings@gocontroll.com>
> >>
> >> media_pad_remote_pad_first() can return NULL if no valid link is found.
> >> Check for this possibility before dereferencing it in the next line.
> >>
> >> Reported/investigated in [1]:
> >>
> >> Link: https://lore.kernel.org/all/1536a61b-b405-4762-9fb4-7e257f95e49e@gocontroll.com/ [1]
> >> Fixes: cf21f328fcaf ("media: nxp: Add i.MX8 ISI driver")
> >> Signed-off-by: Maud Spierings <maudspierings@gocontroll.com>
> >> ---
> >> I'm not sure if this should be a dev_dbg(), just following the pattern
> >> around it for now, also not sure if EPIPE is the correct error.
> > 
> > I've submitted
> > https://lore.kernel.org/linux-media/20250820140021.8026-1-laurent.pinchart@ideasonboard.com,
> > which should fix this issue in a more generic way.
> 
> Saw it, but I think my patch technically is still correct as the 
> function documentation states it can potentially return NULL right? [1]

The function documentation states

"returns a pointer to the pad at the remote end of the first found
enabled link, or NULL if no enabled link has been found."

The MUST_CONNECT flag ensures that there is an enabled link, so the
function can't return NULL.

> Link: 
> https://www.kernel.org/doc/html/latest/driver-api/media/mc-core.html [1]
> 
> I will test you patches tomorrow.
> 
> >> ---
> >>   drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c | 7 +++++++
> >>   1 file changed, 7 insertions(+)
> >>
> >> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> >> index ede6cc74c0234049fa225ad82aaddaad64aa53d7..1ed8b031178b7d934b04a8752747f556bd1fc5a9 100644
> >> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> >> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
> >> @@ -160,6 +160,13 @@ mxc_isi_crossbar_xlate_streams(struct mxc_isi_crossbar *xbar,
> >>   	}
> >>   
> >>   	pad = media_pad_remote_pad_first(&xbar->pads[sink_pad]);
> >> +
> >> +	if (pad == NULL) {
> >> +		dev_dbg(xbar->isi->dev, "no valid link found to pad %u\n",
> >> +			sink_pad);
> >> +		return ERR_PTR(-EPIPE);
> >> +	}
> >> +
> >>   	sd = media_entity_to_v4l2_subdev(pad->entity);
> >>   	if (!sd) {
> >>   		dev_dbg(xbar->isi->dev,
> >>
> >> ---
> >> base-commit: 3ac864c2d9bb8608ee236e89bf561811613abfce
> >> change-id: 20250818-imx8_isi-954898628bb6

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2025-08-20 14:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-18 12:31 Maud Spierings via B4 Relay
2025-08-20 14:01 ` Laurent Pinchart
2025-08-20 14:07   ` Maud Spierings
2025-08-20 14:14     ` Laurent Pinchart [this message]
2025-10-02 16:30       ` ChaosEsque Team

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250820141439.GA10547@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=aisheng.dong@nxp.com \
    --cc=c.hemp@phytec.de \
    --cc=festevam@gmail.com \
    --cc=guoniu.zhou@nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=jacopo@jmondi.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=maudspierings@gocontroll.com \
    --cc=mchehab@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=s.riedmueller@phytec.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®