25c9bac13a2bfeda4d9d9a1cce8b6f01b4e433d1
[openwrt/staging/neocturne.git] /
1 From 0cc1acc72364d72e8cae56ad6eea797bad00e3c5 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 @@ -3109,6 +3109,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