From patchwork Tue Feb 14 22:20:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13140967 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 D8CD1C05027 for ; Tue, 14 Feb 2023 22:22:00 +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=6oj90u0rT1AFzXxvkXNCC344K3xEnGGfDKxB+44qIdw=; b=dpoRZ6pXUvoEb1 wweq0F/bREt+CJnX6KAhwzXTKHuBeH7/SVad9c/TmtJFfKN9D+0jtLOKJqWIWskm0SnKXmtUFDrYr nh2uUSw/KxkWrkx9nuXZtjkMygn8zi25h6hr/hw746ondKk4iHkOESnKRnSVBc/ENp8vgvs0ZpvyT pE8T6nBgjaUsPcn2cJ8MTG7q8ieAMxLNzfGn+Vilc+15CYDgPZ02xajO4Qi9yUlcRFyhe4xxsKZiy TAHhjIGR4xzpU8jA4KWofsRXOuRYCH1qlx+bz0xN6d4JAqdFnpOvmr6YnU+2ElBBD6yB0zAbyZOaN g9zNvD4sRHtpKkdY+VNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pS3fO-003lI7-7g; Tue, 14 Feb 2023 22:20:50 +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 1pS3fJ-003lGV-OL for linux-arm-kernel@lists.infradead.org; Tue, 14 Feb 2023 22:20:47 +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 F20648597D; Tue, 14 Feb 2023 23:20:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1676413235; bh=6lQnqa5Ho4Bz6/mJICnn0i845HTYucwYtLbjsjL3e24=; h=From:To:Cc:Subject:Date:From; b=K5XJhpZ5s1HiccBic2/BviwKazCrvOXT0qF7yRHnaL5AHRciZuTMhWKI8O1RkSafh X/6h0cpF94h5jsiMqT7IAxSGJ8x8EXu1QIyzlutvU2nz4S1SCO6J6gImWW+mZYjxcY 89ScvuTOvDbULkuZjVpPzsC8s6MMxcrMMVGdGKuWqtYKOtOsiknBspxdwEGC2HfPKj nQcmGLCXfknkBYzVNgYOOLRiDI7QHKPPs/fIxqu+jyENkArVpGLJFt+JvPziROpL+e 1e2ICBwE2To7476QrFSw10i8UJBgShOkqg5XJfcxW8izbWGQ54+8WUtC8Hr0MFJdO4 C8xjqwgferUyQ== 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 , Philipp Zabel , Rui Miguel Silva , Sascha Hauer , Shawn Guo , linux-arm-kernel@lists.infradead.org Subject: [PATCH] media: imx-mipi-csis: Check csis_fmt validity before use Date: Tue, 14 Feb 2023 23:20:24 +0100 Message-Id: <20230214222024.165956-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-20230214_142046_066229_DA62E44D X-CRM114-Status: GOOD ( 11.37 ) 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. Fixes: 11927d0fd0d0 ("media: imx-mipi-csis: Use V4L2 subdev active state") Signed-off-by: Marek Vasut Reviewed-by: Laurent Pinchart --- 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 --- drivers/media/platform/nxp/imx-mipi-csis.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c index e99633565463e..8e307ca0b5688 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -1108,6 +1108,8 @@ static int mipi_csis_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, fmt = v4l2_subdev_get_pad_format(sd, state, CSIS_PAD_SOURCE); csis_fmt = find_csis_format(fmt->code); v4l2_subdev_unlock_state(state); + if (!csis_fmt) + return -EINVAL; fd->type = V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL; fd->num_entries = 1;