media: bcm2835-unicam: Set ret on error path in unicam_async_complete()
authorNathan Chancellor <nathan@kernel.org>
Tue, 1 Feb 2022 00:23:38 +0000 (17:23 -0700)
committerDom Cobley <popcornmix@gmail.com>
Mon, 21 Mar 2022 16:04:39 +0000 (16:04 +0000)
commit628eedf6db11ad1df08f4a037e7e116b3796e212
tree3f621bddab2a62a8129b787676635c8639ef7c22
parentcd0284a6f27865618df3870c14ffde29b17bf98a
media: bcm2835-unicam: Set ret on error path in unicam_async_complete()

Clang warns:

  drivers/media/platform/bcm2835/bcm2835-unicam.c:3109:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
          if (!source_pads) {
              ^~~~~~~~~~~~
  drivers/media/platform/bcm2835/bcm2835-unicam.c:3152:9: note: uninitialized use occurs here
          return ret;
                 ^~~
  drivers/media/platform/bcm2835/bcm2835-unicam.c:3109:2: note: remove the 'if' if its condition is always false
          if (!source_pads) {
          ^~~~~~~~~~~~~~~~~~~
  drivers/media/platform/bcm2835/bcm2835-unicam.c:3091:9: note: initialize the variable 'ret' to silence this warning
          int ret;
                 ^
                  = 0
  1 warning generated.

When the if condition is true, ret will be used uninitialized, which
could result in undesirable behavior. Set ret to -ENODEV on the error
path, which is a standard error code for the ->complete() callback.

Fixes: d056e86eb35f ("media/bcm2835-unicam: Parse pad numbers correctly")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
drivers/media/platform/bcm2835/bcm2835-unicam.c