From patchwork Tue Jun 27 10:23:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anastasia Belova X-Patchwork-Id: 113365 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8110880vqr; Tue, 27 Jun 2023 04:09:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7VHOJ5zLITwP6yC2Jfs2WJwa8VhE3PrjIiVoB7z5sV6qE+ESWHdHriKHq0hqviuDRiFnGH X-Received: by 2002:a05:6358:14:b0:130:e0a9:a7b4 with SMTP id 20-20020a056358001400b00130e0a9a7b4mr22953897rww.13.1687864193781; Tue, 27 Jun 2023 04:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687864193; cv=none; d=google.com; s=arc-20160816; b=tAcY1TmjNmN7FLiQRsV15Jnt/IuvgAIP74Nrc7v2NgpK5pb1s7DUySYOtW3tJqt0vo IKgiL+vLUzfrATQu/wB9SY5b1SBu27SMOoDAFp/aoOdvUR2Fkum03Ea/G13IA5agYpIv t/RBQ1YZ9NYDxvJjyE1/ShSZtm5rPgbViAjhWyIPt2wtsz8TOWamtM4+mvOYrjMD+Gj0 w2Oks9Uz7Dn+7l5fdabxlhFWVbgao6QZ6wp0IC5LYNhZBKvUvuxpFgpcQhXK+MYTUmaF BCmiAeUcyOeY2kvMKEpKEnvXTQz5T8ke0xBaBbkv3ks21NHttniqzhjE3Z0Ay49wb1eu /rlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9/R5WtEAnC358s/Jk+igQHCVjG/mumg68dnlpwksYWU=; fh=fqVoJBjbGV5Hrrbeveq1c2DQZO3YH/j4cHguuGxYZN4=; b=QPURsDod7ruu37c4DTclorVMebzX1059kYILG0tvCQjPSyYYfpPlQuKrSRXCIIJqsX ngdB5OlupD6RqJi3GLqiw0r3HZRN7/0M3+4fFqN+nQwzKTsQWptDEsIb7Ytc+RkBVYVL lTdscXUz5PjsRchYkjs1xqcVLjiERHrYcrcJelUcU4Dt8ogvMQxE0LXWavarrdir+mvh 7enmys2lGJ5ZBMc+oH9RktRNnhqVDgcz9vIEKdgpuAcZ7eC6nTE9KnyTBTPHVO4C1xq3 WHloexa6RwR7wkPDsGnot8ibWvFVQe4ieUiLD58FzzJD0CmPgSA2sPizlhrgyh/+u48t dpDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j10-20020a63594a000000b005440e9ee0b2si7123588pgm.569.2023.06.27.04.09.40; Tue, 27 Jun 2023 04:09:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231985AbjF0KZv (ORCPT + 99 others); Tue, 27 Jun 2023 06:25:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230479AbjF0KZN (ORCPT ); Tue, 27 Jun 2023 06:25:13 -0400 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1A8D3AA3; Tue, 27 Jun 2023 03:23:53 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id A7DB4186677E; Tue, 27 Jun 2023 13:23:51 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id nhyyPPXG8I23; Tue, 27 Jun 2023 13:23:51 +0300 (MSK) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 079BA1866712; Tue, 27 Jun 2023 13:23:51 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id GJLLlds1rppm; Tue, 27 Jun 2023 13:23:50 +0300 (MSK) Received: from anastasia-huawei.. (unknown [89.222.134.55]) by mail.astralinux.ru (Postfix) with ESMTPSA id 23BD41865B39; Tue, 27 Jun 2023 13:23:49 +0300 (MSK) From: Anastasia Belova To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Anastasia Belova , Mauro Carvalho Chehab , Sakari Ailus , Xiaomeng Tong , Tsuchiya Yuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, Dan Carpenter , Mauro Carvalho Chehab Subject: [PATCH 5.10 1/1] media: atomisp: fix "variable dereferenced before check 'asd'" Date: Tue, 27 Jun 2023 13:23:34 +0300 Message-Id: <20230627102334.18781-2-abelova@astralinux.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627102334.18781-1-abelova@astralinux.ru> References: <20230627102334.18781-1-abelova@astralinux.ru> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769853884606137779?= X-GMAIL-MSGID: =?utf-8?q?1769853884606137779?= From: Tsuchiya Yuto commit ac56760a8bbb4e654b2fd54e5de79dd5d72f937d upstream. There are two occurrences where the variable 'asd' is dereferenced before check. Fix this issue by using the variable after the check. Link: https://lore.kernel.org/linux-media/20211122074122.GA6581@kili/ Link: https://lore.kernel.org/linux-media/20211201141904.47231-1-kitakar@gmail.com Reported-by: Dan Carpenter Signed-off-by: Tsuchiya Yuto Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Anastasia Belova --- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 3 ++- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 20c19e08968e..613bd9620224 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -5243,7 +5243,7 @@ static int atomisp_set_fmt_to_isp(struct video_device *vdev, int (*configure_pp_input)(struct atomisp_sub_device *asd, unsigned int width, unsigned int height) = configure_pp_input_nop; - u16 stream_index = atomisp_source_pad_to_stream_id(asd, source_pad); + u16 stream_index; const struct atomisp_in_fmt_conv *fc; int ret, i; @@ -5252,6 +5252,7 @@ static int atomisp_set_fmt_to_isp(struct video_device *vdev, __func__, vdev->name); return -EINVAL; } + stream_index = atomisp_source_pad_to_stream_id(asd, source_pad); v4l2_fh_init(&fh.vfh, vdev); diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 8a0648fd7c81..4615e4cae718 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -1123,7 +1123,7 @@ int __atomisp_reqbufs(struct file *file, void *fh, struct ia_css_frame *frame; struct videobuf_vmalloc_memory *vm_mem; u16 source_pad = atomisp_subdev_source_pad(vdev); - u16 stream_id = atomisp_source_pad_to_stream_id(asd, source_pad); + u16 stream_id; int ret = 0, i = 0; if (!asd) { @@ -1131,6 +1131,7 @@ int __atomisp_reqbufs(struct file *file, void *fh, __func__, vdev->name); return -EINVAL; } + stream_id = atomisp_source_pad_to_stream_id(asd, source_pad); if (req->count == 0) { mutex_lock(&pipe->capq.vb_lock);