Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3386589pxb; Mon, 17 Jan 2022 19:18:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOkSVoT1busAD2RqfZfr6ifDT4Vom6IlXRKxzMzUJ0aOXWPP/agLBvtBiauI5YJjoTOrwj X-Received: by 2002:a63:1257:: with SMTP id 23mr4730364pgs.276.1642475901917; Mon, 17 Jan 2022 19:18:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642475901; cv=none; d=google.com; s=arc-20160816; b=Y0Xnlx6EQ4KJRKnaSiYmGhh43oTxnDRJd7FlsCJtUpE8eHxm2MdUTSdi/dictHsJ/i QO57k4gQ6l63tuwlcdFuAN8IGoc2dUvCS53VrrtY4vRK6niN7oVFHSnRNgYOTZs+0/qb ZgIxMUW1ai/MDlw8+jX9rGytL7eaa/9kZt7ZE63qsm9jDCfNgRQHZ15nu6g+XOBgdWNq QxW0J1iUkh8k4WqrBxKw9p4v2YFQHddEjcuI6IRrMhNEIPv9leLIcZilbT/tk0BEwdr1 4N2zT8okeukfAMUj5H2IqwDpHrJO/O7gMmWBx1On1Ju18fPx+yKzygn69V5t8BZG5bYY wQTA== 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 :dkim-signature; bh=B7wBlQaO+QR1etDq9w+iIQmLhiL9sGMKkUKbQaNor6Y=; b=znoMd8taNhTSueSlou31dz57XHW3pQofhxsWrd07ubCzAuTPu7blio2FuRD4RxMKSL IJK/YuMCh3hpcThf0FEvRVmj5UdyuE2jaGA/rpRBNWvriWQTLx5xGuuxJJ+M3yeK5eTK 9SGUXIpSSGyZsxfNlMpUT34YSJP7JWXxwlvVMdxRZfNnIhnUZ7WIH3dvXhqOefpRXGNe 9E9grXIZR68HILYhbcGwIlgLA8lIzy15IsIQiX1Sds/9Rib4W7+4lLKM2TmqYYemgv3H 8fnwcCz2nJPS0id8eNbNRKkXkZH/qgx8iJgwCQx6to+E2pDc+X+fQK8X8MYTzVojNxkl GvWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u1ve0xaO; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z7si16771589plg.555.2022.01.17.19.18.07; Mon, 17 Jan 2022 19:18:21 -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=@kernel.org header.s=k20201202 header.b=u1ve0xaO; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245531AbiARC2h (ORCPT + 99 others); Mon, 17 Jan 2022 21:28:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245040AbiARC0S (ORCPT ); Mon, 17 Jan 2022 21:26:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DA4AC061401; Mon, 17 Jan 2022 18:24:53 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id AF9BA60AAF; Tue, 18 Jan 2022 02:24:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C928C36AEB; Tue, 18 Jan 2022 02:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472692; bh=t6EK6nXBYsJjngzkuNBBOsN4uXBS60XMMOEjqfzHALs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u1ve0xaOc+iGFCLZZzYQncyMvMloLl8ztPGcI9bpe7WitCqfi2UWNgqvBNu6lEPV9 q5OXvRsytErQOWqCgQd8EYKDz4W2rtosqxYAHMnko/Py+ewX6tudA5iYiytkU0kc5x /EZRoSeKv0RIQirJH62TpB1nPSRHg72GwXpIOS5147xlKahfC48PP/JLY/DY5kLgPU SjeGN5RvGhougfkO9KcQZtKs/MzbMab8OhEdr+xEJlMJr7CMywYAtqJKHCSMLzPpXD Q6/iXwEgNVTguItIGz3X+5Hvd+Z/nccAzEFkRrYqToa39jvTOsAZI5RFV2jD7evbx7 bDKdP+zCEkCvg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tsuchiya Yuto , Dan Carpenter , Mauro Carvalho Chehab , Sasha Levin , mchehab@kernel.org, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, arnd@arndb.de, tomi.valkeinen@ideasonboard.com, alex.dewar90@gmail.com, alinesantanacordeiro@gmail.com, peterz@infradead.org, andriy.shevchenko@linux.intel.com, kaixuxia@tencent.com, linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH AUTOSEL 5.16 100/217] media: atomisp: fix "variable dereferenced before check 'asd'" Date: Mon, 17 Jan 2022 21:17:43 -0500 Message-Id: <20220118021940.1942199-100-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 442446e5d59f7..3861e794272ea 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -1112,7 +1112,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) { @@ -1120,6 +1120,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