Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp3103936ybj; Mon, 23 Sep 2019 14:57:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqySXo+/D0vpn3iPvBfEd9K64z7hek6IpwqixNoppIpV6bfVYuge8O183Zluf3ah/R2Mzt1B X-Received: by 2002:a50:f78a:: with SMTP id h10mr2400556edn.161.1569275828579; Mon, 23 Sep 2019 14:57:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569275828; cv=none; d=google.com; s=arc-20160816; b=HhEigzpebsacQdleQ3vJ9ywWj1k/wSlka3y7TKf3A5yjOONHYE8CRyfd5+6p8iVbM2 hRUEfFeq0itMF9sm73XgXVfBknq7/PyEmDRIuvSGPNNGmaRrb988LU3/IBFb4xcQjpot kWGaUCsya6+oy0IlxBh22Y4xcZj0vMoK+WbEEWxg6ozELfLE1SDhyaoNsZYJsTXi4+2q V2R+8Ujrf9yl5HCfDx0AJM+Axt7xKuxb73og6LR0UyMo0bpaJieRVd9iwirVT1gQJfp1 fIbEdQBHDG/Gip5zM+UcT7FVTYSYpeGjqkU7yIB5yJ925ZmLbBH6GwLUPSwgzD1A5AB5 862g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=U9YFDqgC1wFA1ENwH+K5KYfPMNtSKuwqTBSHAwVXxqs=; b=rtprkDqn7iAiap/qoFidBPKyiFb7JSQJpHturgXSDfe8lg/h/iAMRrB6AtSEsQarQR TkYZanvzyAre6AyRm1x0R2y/wMluavP1QyfdB6263tUwJTPxUvhtNzwZMk1UvAiPXru6 9CHIP+TtdUZ0d4A3d0rSPmQgHlIrAD3AuyoxHIK9vusCdbVtH2S/HRFZaNNKbs2OElP8 dvfe2gsG7pKO37MixTXTnIm0BP/ioSUW2McaOhhOeqCG3YymbVmPuhPcE7G8x011RHok k/xrwwkTXBI9gWk6XC22cxs8De23R7bCyHTtazvvSl1uRH9YW2j/KCtop3ekjkcfsI4V ld7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rakboH4x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id np3si6065068ejb.384.2019.09.23.14.56.44; Mon, 23 Sep 2019 14:57:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rakboH4x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2391026AbfIVSrg (ORCPT + 99 others); Sun, 22 Sep 2019 14:47:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:44002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390929AbfIVSre (ORCPT ); Sun, 22 Sep 2019 14:47:34 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DBD2521907; Sun, 22 Sep 2019 18:47:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569178053; bh=kmV+YHG6BmNnd6KqVNhoq9PwNagd3wWpcvAWi409cOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rakboH4xAAebeB+eUET4rrt7MiczD/0rI5Dri+cDN7p2PWWDn2kO3sGc8TCxPH1/c QAyvgh2nsEffCm6scggyG2gcuN/9A4opknwALzveihkfiiqK84wJaqwXN7nEH5AWuv ZtVOOXWnkpdMP1emlHXmcZPSkO3hq8SPgAfFhfWU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mauro Carvalho Chehab , Eddie James , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.3 130/203] media: aspeed-video: address a protential usage of an unitialized var Date: Sun, 22 Sep 2019 14:42:36 -0400 Message-Id: <20190922184350.30563-130-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190922184350.30563-1-sashal@kernel.org> References: <20190922184350.30563-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mauro Carvalho Chehab [ Upstream commit 31b8b0bd6e55c3ea5a08bb8141fa5d3c90600e3b ] While this might not occur in practice, if the device is doing the right thing, it would be teoretically be possible to have both hsync_counter and vsync_counter negatives. If this ever happen, ctrl will be undefined, but the driver will still call: aspeed_video_update(video, VE_CTRL, 0, ctrl); Change the code to prevent this to happen. This was warned by cppcheck: [drivers/media/platform/aspeed-video.c:653]: (error) Uninitialized variable: ctrl Reviewed-by: Eddie James Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/aspeed-video.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c index f899ac3b4a613..4ef37cfc84467 100644 --- a/drivers/media/platform/aspeed-video.c +++ b/drivers/media/platform/aspeed-video.c @@ -630,7 +630,7 @@ static void aspeed_video_check_and_set_polarity(struct aspeed_video *video) } if (hsync_counter < 0 || vsync_counter < 0) { - u32 ctrl; + u32 ctrl = 0; if (hsync_counter < 0) { ctrl = VE_CTRL_HSYNC_POL; @@ -650,7 +650,8 @@ static void aspeed_video_check_and_set_polarity(struct aspeed_video *video) V4L2_DV_VSYNC_POS_POL; } - aspeed_video_update(video, VE_CTRL, 0, ctrl); + if (ctrl) + aspeed_video_update(video, VE_CTRL, 0, ctrl); } } -- 2.20.1