Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4638113pxt; Wed, 11 Aug 2021 10:25:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNerw+h4LyLOobiGDy6+0kjCMwnUy54ir7ehsy91W4BZmG5C6J398HHFAGqgkb+zfYtIQZ X-Received: by 2002:a05:6402:1d19:: with SMTP id dg25mr12448359edb.153.1628702705054; Wed, 11 Aug 2021 10:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628702705; cv=none; d=google.com; s=arc-20160816; b=SFNrtfTv+RFGDL1ATgtMcDfA2fg2TlzxO8YN/OoPGJkw/VhhahGCrwqz+bl6Y0j5xK qJhwb6H4e/34IBUJ1gxtvM8AuT26n4aT7mrJ8YBpPgc6AvYOjF2fa6P4mkAxYd7zw4ti PWDo/iSPuQbz1VkSxkUWgHxuCgjsWR10W0XF4NqeuSlU4d01K1+e2Tz7RSXXD4kT45u8 BPoQx4yfCxLJPDr/YviqBu+kR+egvogxARjJgxJWihGhCJRD02SchzCZ9kSfHj2fsR9B 2TuLgM/jBbdGUh0Q4+jTdWfMZsrYTAudHNNdTF90rmUNQukSdTmXHDmOOxbFG20z0iVd lVxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:message-id:date:subject:cc:to:from; bh=qiZiSY70z0oyDt/FPQ/lTDx6HEMu5TEggy/7s4pYGE0=; b=Y1Wpb5Ht+cZ1M6xYXirHvDtQwoLClBns3SSuySQKGqybFbux4kxJBjs6PVqeb2PsXq Ky5GeM4z773/EqAxJuDSWIbJgkYAt3o3BOp/n46bTv0CdqpSp0FJVDv7WkaMZL5XsQPc ESL6sNNZF9RrjTNYEPZ+b9t1hf2iXsZsb3BIkJa8VpAcyHyhKrz+2i4fiMqEcAT+2n69 hkjrJ0+4Fl14gfBsdKx1q0JOBn1PLtfPbCUBDa7R45DgDa4x5ukyHu820zSNhtRIA1K3 fgA0W4eA5E6li+EozZCo9/WZUGOmVNoLkAZq7QiK0QtHq9g88B1l8UUtQVZu1J3CNNCo HUKQ== 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 dn3si24682496edb.75.2021.08.11.10.24.39; Wed, 11 Aug 2021 10:25:05 -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 S230474AbhHKRUA (ORCPT + 99 others); Wed, 11 Aug 2021 13:20:00 -0400 Received: from mail.ispras.ru ([83.149.199.84]:39904 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229976AbhHKRT7 (ORCPT ); Wed, 11 Aug 2021 13:19:59 -0400 Received: from kleverstation.intra.ispras.ru (unknown [10.10.2.220]) by mail.ispras.ru (Postfix) with ESMTPS id BC28A400FC5B; Wed, 11 Aug 2021 17:19:33 +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 v2] media: rcar-csi2: Add checking to rcsi2_start_receiver() Date: Wed, 11 Aug 2021 20:18:16 +0300 Message-Id: <20210811171816.12012-1-lutovinova@ispras.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: 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. That should not be possible now but adding checking protects from future bugs. The patch adds checking if format is NULL. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Nadezda Lutovinova --- v2: fix subject and commit message, remove dev_err() --- drivers/media/platform/rcar-vin/rcar-csi2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index e28eff039688..d28f83f7698b 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -553,6 +553,8 @@ 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) + return -EINVAL; /* * Enable all supported CSI-2 channels with virtual channel and -- 2.17.1