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: 13142393 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58E15C636D4 for ; Thu, 16 Feb 2023 01:45:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=JPzhPNNdu9Lh2MotZCaUcqAk5HeRdiD7auGpHFsoySw=; b=cSHNyoEWzfckcs YDK7j8QwSnLNy/s8EDNFTB/OLufSZ8qxUgCEhUeGEZSdIpt1fnxuZN9zVvG+YVeZNwndiPyKqmF9A idswCJEN0EwJAdDARumTcC1cdrF3Azc6e1eRnXYhM02Q0P3Up6295uEXPas8pdW7SaC+WDQ1Wt9NN ZRV96DWzqsHzpQMN7GDapibwnCBWot0MQp1QLbjNm1EAltXNWBwS8m41X1EwySz9CdXviC204Du9B GCsb33MWRSiR7VCVY8u8Y3JBiOqySpSFAfVoQlTWKCi3FUqzl/NQDeS9KKlU+KAaZ12Po7w6WES7A Nbz+ESseQ+37e/s6b1pA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSTJs-008E7h-5W; Thu, 16 Feb 2023 01:44:20 +0000 Received: from phobos.denx.de ([85.214.62.61]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSTJo-008E6k-1y for linux-arm-kernel@lists.infradead.org; Thu, 16 Feb 2023 01:44:18 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230215_174416_289616_5E733F90 X-CRM114-Status: GOOD ( 11.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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;