e604817c908027c6c6acbdb230c0c6693a0469d2
[openwrt/staging/blocktrron.git] /
1 From 7104c55664bae574b77e442520513abdff90d278 Mon Sep 17 00:00:00 2001
2 From: Nathan Chancellor <nathan@kernel.org>
3 Date: Mon, 31 Jan 2022 17:23:38 -0700
4 Subject: [PATCH] media: bcm2835-unicam: Set ret on error path in
5 unicam_async_complete()
6
7 Clang warns:
8
9 drivers/media/platform/bcm2835/bcm2835-unicam.c:3109:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
10 if (!source_pads) {
11 ^~~~~~~~~~~~
12 drivers/media/platform/bcm2835/bcm2835-unicam.c:3152:9: note: uninitialized use occurs here
13 return ret;
14 ^~~
15 drivers/media/platform/bcm2835/bcm2835-unicam.c:3109:2: note: remove the 'if' if its condition is always false
16 if (!source_pads) {
17 ^~~~~~~~~~~~~~~~~~~
18 drivers/media/platform/bcm2835/bcm2835-unicam.c:3091:9: note: initialize the variable 'ret' to silence this warning
19 int ret;
20 ^
21 = 0
22 1 warning generated.
23
24 When the if condition is true, ret will be used uninitialized, which
25 could result in undesirable behavior. Set ret to -ENODEV on the error
26 path, which is a standard error code for the ->complete() callback.
27
28 Fixes: d056e86eb35f ("media/bcm2835-unicam: Parse pad numbers correctly")
29 Signed-off-by: Nathan Chancellor <nathan@kernel.org>
30 ---
31 drivers/media/platform/bcm2835/bcm2835-unicam.c | 1 +
32 1 file changed, 1 insertion(+)
33
34 --- a/drivers/media/platform/bcm2835/bcm2835-unicam.c
35 +++ b/drivers/media/platform/bcm2835/bcm2835-unicam.c
36 @@ -3108,6 +3108,7 @@ static int unicam_async_complete(struct
37 }
38 if (!source_pads) {
39 unicam_err(unicam, "No source pads on sensor.\n");
40 + ret = -ENODEV;
41 goto unregister;
42 }
43