diff options
author | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-08-22 11:46:40 -0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-10-05 13:13:49 +0200 |
commit | 826a67380c4a98b6d69774038224c1ce94c51691 (patch) | |
tree | 847e8466b77eda2a1ea0a8a3a9c17d6976bcfd1d /drivers/media | |
parent | c10ea8447736b8c6041f4d3232a3cc4e95ebe4e0 (diff) | |
download | linux-stable-826a67380c4a98b6d69774038224c1ce94c51691.tar.gz linux-stable-826a67380c4a98b6d69774038224c1ce94c51691.tar.bz2 linux-stable-826a67380c4a98b6d69774038224c1ce94c51691.zip |
media: aspeed-video: address a protential usage of an unitialized var
[ 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 <eajames@linux.ibm.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/platform/aspeed-video.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c index de0f192afa8b..388c32a11345 100644 --- a/drivers/media/platform/aspeed-video.c +++ b/drivers/media/platform/aspeed-video.c @@ -632,7 +632,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; @@ -652,7 +652,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); } } |