Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3384049pxb; Mon, 17 Jan 2022 19:13:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzj1P8xBy/0mR4q+Oj3vmuGNmmfdnNLmJS7KodS3oAPx+2a/YsYDMKeEh54uDMP+8W5DcZQ X-Received: by 2002:a17:902:a405:b0:14a:b276:fc9e with SMTP id p5-20020a170902a40500b0014ab276fc9emr9673672plq.127.1642475608056; Mon, 17 Jan 2022 19:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642475608; cv=none; d=google.com; s=arc-20160816; b=hdNMLdAt/m2P0IUQt3Wa9kI/dFbWadstucbVnBck7jetcA19TvS7J1q+HTsoSrH+Gm azu1I490V74524eK9GU7cJ+qOYutjQLhYFCdt6I7HSaOv6TB52mYYk8/yewaYeArCxUH BhT4OzYipO8l1K8/JszgC4PJHFuT+NCg0kYW7bI1RbKag4h0UrWygyfpzhHmh1b8Y2LZ qT3K/CWyej5O0RhYz9IR8+5yx861gkjaKBY5YIlP4qGI6S2FMtZ+i8qH8Eusho5Egvfq IOhXTCGwKkLDR8XkO9DQrNdh6rVNWAz1eousQefIMQHQ5p1NJyDfEBf4+zjE/sp8WoTs 3tsw== 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=f/MZySzPikHmpGI0KAHRBTaPB/yBMNE18Ii18hYLS4c=; b=iHB82rzCHPYfF3QAUAvlv1sF+tLta9gS/QQ8CdqX/9KVzIPxXuVwXgb6OudDD+5tYM TJ1iLoT5YSB3sI4jQrdd0Rw/zAJsbXEtv1wto/w3MF5VsD9YIOGDaeDZZ+c4bpYdEsgL 5gGCVpBLyWPhBASg1mvj128khFPanTRwUZ89BhGyxl4utFOUHGbGCQED4NkgzVXJU6Ll 6qYikJX117qxwNotF5AWI8EPkP4QH9dvC2eQoIikmF+LAqUgLtgJ50XPocbA2EvvvHej eZRjLOv7DrnmuQ+l5Y0wf/PuKiT2sarCscdsBJwd2oGcHgZGYdi1UxNCcRoSbbhBhW3Z AfGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HvZ44EzX; 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 h192si15609818pgc.401.2022.01.17.19.13.16; Mon, 17 Jan 2022 19:13:28 -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=HvZ44EzX; 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 S244472AbiARCVs (ORCPT + 99 others); Mon, 17 Jan 2022 21:21:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244675AbiARCVJ (ORCPT ); Mon, 17 Jan 2022 21:21:09 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FCA6C061769; Mon, 17 Jan 2022 18:21:08 -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 ams.source.kernel.org (Postfix) with ESMTPS id 57A9CB8122C; Tue, 18 Jan 2022 02:21:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3CFBC36AEB; Tue, 18 Jan 2022 02:21:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472466; bh=oN+riz2KPBpT4JWOx2X4OywlB2pWHJD4t8/cTC9SMSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HvZ44EzXkUAJDymBLi0xca+pVRZjoSLL7CslTwxTTYEySkGqt+Ye5SUxZ6aA0roTX SGXMIQSQnfnVdT2/vhe6GdT1qWprevH1nYEgG723diX5q4lUgMXfUO+/o0NDvLOFev BeXxJqIhUsp+/kkVVLcSrK/cdI2Z4RPVfugwFQ1E8+XSQrASqKwq6Yw3xFGQ8nJ1a/ 1BOd8ydNpNUR9au2BT6tPDJbsof+lZip4zh36ELB6VsohIVHx4ka+tZmsz3BpuxwRB aznhBPt7yTsyIAaX6xLUyAQPX2lY5j1VR0HDttUMZ+ZA+OMHDz1Duxcmo4/Awy9dep 0WOEQmOpBs/pw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mauro Carvalho Chehab , Sasha Levin , mchehab@kernel.org, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, kitakar@gmail.com, arnd@arndb.de, tomi.valkeinen@ideasonboard.com, alex.dewar90@gmail.com, alinesantanacordeiro@gmail.com, linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH AUTOSEL 5.16 022/217] media: atomisp: check before deference asd variable Date: Mon, 17 Jan 2022 21:16:25 -0500 Message-Id: <20220118021940.1942199-22-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: Mauro Carvalho Chehab [ Upstream commit 71665d816214124d6bc4eb80314ac8f84ecacd78 ] The asd->isp was referenced before checking if asd is not NULL. This fixes this warning: ../drivers/staging/media/atomisp/pci/atomisp_cmd.c:5548 atomisp_set_fmt_to_snr() warn: variable dereferenced before check 'asd' (see line 5540) While here, avoid getting the pipe pointer twice. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 6 ++++-- 1 file 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 75a531667d743..1ddb9c815a3cb 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -5529,8 +5529,8 @@ static int atomisp_set_fmt_to_snr(struct video_device *vdev, unsigned int padding_w, unsigned int padding_h, unsigned int dvs_env_w, unsigned int dvs_env_h) { - struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd; struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev); + struct atomisp_sub_device *asd = pipe->asd; const struct atomisp_format_bridge *format; struct v4l2_subdev_pad_config pad_cfg; struct v4l2_subdev_state pad_state = { @@ -5541,7 +5541,7 @@ static int atomisp_set_fmt_to_snr(struct video_device *vdev, }; struct v4l2_mbus_framefmt *ffmt = &vformat.format; struct v4l2_mbus_framefmt *req_ffmt; - struct atomisp_device *isp = asd->isp; + struct atomisp_device *isp; struct atomisp_input_stream_info *stream_info = (struct atomisp_input_stream_info *)ffmt->reserved; u16 stream_index = ATOMISP_INPUT_STREAM_GENERAL; @@ -5555,6 +5555,8 @@ static int atomisp_set_fmt_to_snr(struct video_device *vdev, return -EINVAL; } + isp = asd->isp; + v4l2_fh_init(&fh.vfh, vdev); stream_index = atomisp_source_pad_to_stream_id(asd, source_pad); -- 2.34.1