From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05483C4338F for ; Thu, 12 Aug 2021 09:25:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2FA160C3F for ; Thu, 12 Aug 2021 09:25:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236157AbhHLJZa (ORCPT ); Thu, 12 Aug 2021 05:25:30 -0400 Received: from mslow1.mail.gandi.net ([217.70.178.240]:57953 "EHLO mslow1.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231392AbhHLJZR (ORCPT ); Thu, 12 Aug 2021 05:25:17 -0400 Received: from relay9-d.mail.gandi.net (unknown [217.70.183.199]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 5F419CD329; Thu, 12 Aug 2021 09:15:41 +0000 (UTC) Received: (Authenticated sender: jacopo@jmondi.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 1DE18FF80C; Thu, 12 Aug 2021 09:15:15 +0000 (UTC) Date: Thu, 12 Aug 2021 11:16:03 +0200 From: Jacopo Mondi To: Nadezda Lutovinova Cc: Niklas =?utf-8?Q?S=C3=B6derlund?= , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: Re: [PATCH v2] media: rcar-csi2: Add checking to rcsi2_start_receiver() Message-ID: <20210812091603.ahguetst2v354nla@uno.localdomain> References: <20210811171816.12012-1-lutovinova@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210811171816.12012-1-lutovinova@ispras.ru> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Nadezda, On Wed, Aug 11, 2021 at 08:18:16PM +0300, Nadezda Lutovinova wrote: > 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 Reviewed-by: Jacopo Mondi Thanks j > --- > 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 >