From patchwork Fri Dec 1 15:06:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13475936 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="IcMSvVS5" Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61DAEA8 for ; Fri, 1 Dec 2023 07:06:26 -0800 (PST) Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 3BFBB87684; Fri, 1 Dec 2023 16:06:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1701443183; bh=aG2bxALTPoE/i7BHeVL4NBOIewpYx3YvCkzeCfdeP90=; h=From:To:Cc:Subject:Date:From; b=IcMSvVS5+GHLYHLAJAUtDa3jWvgIwJxBVnOSC+zc0nY4MonaJJ666Zp85oFk5JrYY FaSzR7cjEqABuLSVaP7QPGVzSBE+34P/tjmpNizaq12ILeKbrg+A3PAXI0Q0XR6VLE 35gDHUJhufK083K3wN9v42OWRg0sbL7/sRIX3pZbEzekey2xYrzOd399wowuXqFGB1 9CRTQTuJ3z9nkUqy2okKxte0in4hj08P5TVldI+cIvU6GySoCRRQCPqM2HI54YNv90 xiu7FdYr3Ewaw0/TanPAdIrdTX078qWwQ9MfuqauFlY+DvugFKR6c7N1KavcqWUbdK YvOEWu0efLjJg== From: Marek Vasut To: linux-media@vger.kernel.org Cc: Marek Vasut , Fabio Estevam , Laurent Pinchart , Mauro Carvalho Chehab , NXP Linux Team , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo , linux-arm-kernel@lists.infradead.org Subject: [PATCH] media: nxp: isi: Check whether pad is non-NULL before access Date: Fri, 1 Dec 2023 16:06:04 +0100 Message-ID: <20231201150614.63300-1-marex@denx.de> X-Mailer: git-send-email 2.42.0 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The pad can be NULL if media controller routing is not set up correctly. Check whether the pad is NULL before using it, otherwise it is possible to achieve NULL pointer dereference. Fixes: cf21f328fcaf ("media: nxp: Add i.MX8 ISI driver") Signed-off-by: Marek Vasut Reviewed-by: Fabio Estevam Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Cc: Fabio Estevam Cc: Laurent Pinchart Cc: Mauro Carvalho Chehab Cc: NXP Linux Team Cc: Pengutronix Kernel Team Cc: Sascha Hauer Cc: Shawn Guo Cc: linux-arm-kernel@lists.infradead.org Cc: linux-media@vger.kernel.org --- drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 792f031e032ae..44354931cf8a1 100644 --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c @@ -160,8 +160,14 @@ mxc_isi_crossbar_xlate_streams(struct mxc_isi_crossbar *xbar, } pad = media_pad_remote_pad_first(&xbar->pads[sink_pad]); - sd = media_entity_to_v4l2_subdev(pad->entity); + if (!pad) { + dev_dbg(xbar->isi->dev, + "no pad connected to crossbar input %u\n", + sink_pad); + return ERR_PTR(-EPIPE); + } + sd = media_entity_to_v4l2_subdev(pad->entity); if (!sd) { dev_dbg(xbar->isi->dev, "no entity connected to crossbar input %u\n",