From: Mauro Carvalho Chehab Date: Thu, 22 Aug 2019 14:46:40 +0000 (-0300) Subject: media: aspeed-video: address a protential usage of an unitialized var X-Git-Tag: v5.4-rc1~145^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=31b8b0bd6e55c3ea5a08bb8141fa5d3c90600e3b;p=thirdparty%2Flinux.git media: aspeed-video: address a protential usage of an unitialized var 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 --- diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c index 94f97d96dabc8..eb12f37930629 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); } }