Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4456813pxt; Wed, 11 Aug 2021 06:33:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU0s/LUxlfsXYs4ffClVTuuGAbY0gTyg1n43L+3GsPKHnJ/J54pw6wsfaSlTvbZgStss72 X-Received: by 2002:a17:906:4103:: with SMTP id j3mr3711386ejk.38.1628688832975; Wed, 11 Aug 2021 06:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628688832; cv=none; d=google.com; s=arc-20160816; b=L8kzogyvKDwSPlFGVp0g9UC2vD9saqVaKbg+2rBpvGcrIPROLej93usDXuc3P3N4uX r7xWr1XLM/mvgcXFSZURJBUsp4mp37el5UsItoeroyes5lO744oxFHXXhMO4B+8iL+Xv QfG9o4Jf46ErJRfE6P7vRtCRuiMuTSqOTarirzvMQrUNADm/KFsdCP94q/7g52dkyImQ HuiClW+v5CDtQ87lbrZnz4mnorFn4PX70mZN0/20HNcVulZ3UGF3ek4DgHDc8Fok2p9A Vz99pWZuRO2KbEchBXfVTyJAI+tGKIWAgupJHW3lK26bTdEUI9R0whAlFIrbQaZiAifa OTpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=f/GtYqftQLoyj7foSf20bgbJbMCBfvz1msatLgS9i0U=; b=nlKFlKBHq/MHHWhDp7CoqBcrjOcPAXjhACzSdBtKUP2g8SJYbDyU7fOrY3hiuEhstb S28VuaP04+o+0GYqX9TF4RqgUY8COyBmmMiclqlQvj/bzHDo+/G6i8VOvCIarwNxby2K hOxFlHYy+MugVOqAwtHuT8o3VL9N+bndXtpysdNGAyFkGOkMTGDFmemXZvBuzBfICwh1 Rj4MfcWomUvVAfQuqAqOtOjHDtyh/MYrWO0HRRauLZwkM/1cq0mv9qKI2xVppTSY7wrw KqinYXBxxm/7Y7v3Ac57xTP59AnOVk3f4J+nKoVWOZ842s+YbnMgApabOTxrhSJMzhLW c/cQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si10703797edx.574.2021.08.11.06.33.28; Wed, 11 Aug 2021 06:33:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231577AbhHKNcR (ORCPT + 99 others); Wed, 11 Aug 2021 09:32:17 -0400 Received: from mail.ispras.ru ([83.149.199.84]:38170 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbhHKNcR (ORCPT ); Wed, 11 Aug 2021 09:32:17 -0400 Received: from kleverstation.intra.ispras.ru (unknown [10.10.2.220]) by mail.ispras.ru (Postfix) with ESMTPS id 5A612407625E; Wed, 11 Aug 2021 13:31:52 +0000 (UTC) From: Nadezda Lutovinova To: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Cc: Nadezda Lutovinova , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] media: rcar-csi2: Add checking to rcsi2_start_receiver(). Date: Wed, 11 Aug 2021 16:31:42 +0300 Message-Id: <20210811133142.13363-1-lutovinova@ispras.ru> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If rcsi2_code_to_fmt() return NULL, then null pointer dereference occurs in the next cycle. The patch adds checking if format is NULL. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Nadezda Lutovinova --- drivers/media/platform/rcar-vin/rcar-csi2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index e28eff039688..55bb584d2a13 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -553,6 +553,12 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv) /* Code is validated in set_fmt. */ format = rcsi2_code_to_fmt(priv->mf.code); + if (!format) { + dev_err(priv->dev, + "Incorrect mbus frame format code %u\n", + priv->mf.code); + return -EINVAL; + } /* * Enable all supported CSI-2 channels with virtual channel and -- 2.17.1