Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3608217pxb; Mon, 24 Jan 2022 13:25:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4+Kp3/+wDG76jWQgyOG5JHpB+XjRPPOp8fAbi+jii0GxI7LGWu5z1YXq8Zk94CngQS1P6 X-Received: by 2002:a05:6a00:2410:b0:4bc:dda9:2e92 with SMTP id z16-20020a056a00241000b004bcdda92e92mr15431492pfh.76.1643059509944; Mon, 24 Jan 2022 13:25:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643059509; cv=none; d=google.com; s=arc-20160816; b=Glhsc6d63McEPhk7XUY1v6qAKcHiIRlw1yASP0WBl5W8yLVHWozQo5Y/FDae0RVY/k zKX9rr78uRrCWpB4XQQSAgdK4Oi1IW18+alyGPJJDhQutqNQg3JnZIdHLwS5g0ASiImZ 5YBb1T9VcB0erwXjHOPifO7MpmYepGVOq3v+gw06v6PCA/M5XzvZIy40Z8lQELV1+HxU fJBASQRe/oE/0Tks1b3vwRt/aXniAy2VrrMPtmF+knJort9L6PWLv4H4vrDsTqbz/KJ8 +kWWxg6fM2S06ZptGbyOfoFnw6RzQOw+m3F8d9ejDZq2Ji44abkTILHk+MqVAdJfuRXa +l7w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CsCPgG7OQgqrFcgUpW68AG27+h0UtRMlquFpdkMUuWk=; b=gn8ZQwpDrrT1YA3A/GfNEh+1BglHi083JVRwvEJmvrIu4mbNSpZWLxaAQYDEKliF0u pHkTjOAd7hykpHeLZoa3mzqMxRLH0o5BHH73blMl+QqVFwwpfDmoU3P16MRmWUyv84CX A9Dv/ewAXGptDa9SlH4PkB396oODY2R7360rJCgrWbJno9vBkgZo34ruBm4UWEIwFlYG j0Nq/G3DMao0+Qou/fu+XrpXEEifnpszpIYC+yK69i80SM8fyWVI8qciMH2qx/F19Iut +EDRV3+YS+dBo2j1G2fybZooXr8XBEaayatmno9j5xa10hmBrzoMej7oi/gUxrm//opK RI3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2FgVCyni; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h3si13396892pgb.838.2022.01.24.13.24.58; Mon, 24 Jan 2022 13:25:09 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2FgVCyni; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442746AbiAXU7G (ORCPT + 99 others); Mon, 24 Jan 2022 15:59:06 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:39752 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386908AbiAXUgH (ORCPT ); Mon, 24 Jan 2022 15:36:07 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 706E5B8122C; Mon, 24 Jan 2022 20:36:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F8DDC340E5; Mon, 24 Jan 2022 20:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056565; bh=MwjSNMBDiKF0+H5jqz5A2By0pk1oW/OfxKi+IgH4XTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2FgVCyniUxvFZoR54sMzzGtBXZ/ar+PFvd9679qM34JCWyVNQr6KmuJK4rLzitbOR aLPyZ1JdEunHP1OdJi19mv9f5w2GbIozFPtUF49dFoT0fftu3xp3Azn4WyNFfTyoWH Z8S0tNZPnLqcRsf/+CmGm9NWIsNOhTfpXhNVff3A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Tsuchiya Yuto , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.15 526/846] media: atomisp: fix "variable dereferenced before check asd" Date: Mon, 24 Jan 2022 19:40:43 +0100 Message-Id: <20220124184119.151926726@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tsuchiya Yuto [ Upstream commit ac56760a8bbb4e654b2fd54e5de79dd5d72f937d ] 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: Sasha Levin --- 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 1ddb9c815a3cb..ef0b0963cf930 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -5224,7 +5224,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; @@ -5233,6 +5233,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 54624f8814e04..b7dda4b96d49c 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); -- 2.34.1