From patchwork Thu Feb 16 01:44:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 654316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98133C636D4 for ; Thu, 16 Feb 2023 01:44:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbjBPBoU (ORCPT ); Wed, 15 Feb 2023 20:44:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229771AbjBPBoP (ORCPT ); Wed, 15 Feb 2023 20:44:15 -0500 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6990572BD for ; Wed, 15 Feb 2023 17:44:14 -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 2FB51859E3; Thu, 16 Feb 2023 02:44:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1676511852; bh=cudAEEXaMH1tCYmLEYBtgt9sbj3M5w5kXhMQx/gOO0o=; h=From:To:Cc:Subject:Date:From; b=uhtYaWgA8i++fy7xR61QjA1k96CyrrEYQv10yccez0ZDc0S8QgLhHOT53vDwNyaXj Ta3CrPi/fi0ZaOHKOh0OVvmWReOiibIaoGkCbKtx9GpRL6/BRRAcElgcmS9rjoTxwb v5PXpgvrGSSk5s4ItZZzeE1+oHy6Ny3XsCDHWmdWnvchsrdeoRE9BeLUoyPVUdAgbt Bsdi3aPhkLAORJgdsGgkQBWtyuwdbPbB54qiy1euPtAoIiNYwrX3uX4huXZaN93eum LPMrhujJ2vQowR3pg2hGwkydXrCHz0/TU5WnmNe+iyrbJVD5Y78wpGJ8/VWG3zTFIn LZ/qA0UyNcW+g== From: Marek Vasut To: linux-media@vger.kernel.org Cc: Marek Vasut , Laurent Pinchart , Fabio Estevam , Mauro Carvalho Chehab , NXP Linux Team , Pengutronix Kernel Team , Philipp Zabel , Rui Miguel Silva , Sascha Hauer , Shawn Guo , linux-arm-kernel@lists.infradead.org Subject: [PATCH v3] media: imx-mipi-csis: Check csis_fmt validity before use Date: Thu, 16 Feb 2023 02:44:01 +0100 Message-Id: <20230216014401.225603-1-marex@denx.de> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The find_csis_format() may return NULL in case supported format is not found, check the return value of find_csis_format() before using the result to avoid NULL pointer dereference. Reviewed-by: Laurent Pinchart Fixes: 11927d0fd0d0 ("media: imx-mipi-csis: Use V4L2 subdev active state") Signed-off-by: Marek Vasut --- Cc: Fabio Estevam Cc: Laurent Pinchart Cc: Mauro Carvalho Chehab Cc: NXP Linux Team Cc: Pengutronix Kernel Team Cc: Philipp Zabel Cc: Rui Miguel Silva Cc: Sascha Hauer Cc: Shawn Guo Cc: linux-arm-kernel@lists.infradead.org Cc: linux-media@vger.kernel.org --- V2: Add blank line V3: Return -EPIPE --- drivers/media/platform/nxp/imx-mipi-csis.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c index e99633565463e..be2768a479951 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -1109,6 +1109,9 @@ static int mipi_csis_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, csis_fmt = find_csis_format(fmt->code); v4l2_subdev_unlock_state(state); + if (!csis_fmt) + return -EPIPE; + fd->type = V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL; fd->num_entries = 1;