Skip to content

Commit

Permalink
misc: rtsx_usb: set return value in rsp_buf alloc err path
Browse files Browse the repository at this point in the history
commit 2cd37c2 upstream.

Set return value in rsp_buf alloc error path before going to
error handling.

drivers/misc/cardreader/rtsx_usb.c:639:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!ucr->rsp_buf)
               ^~~~~~~~~~~~~
   drivers/misc/cardreader/rtsx_usb.c:678:9: note: uninitialized use occurs here
           return ret;
                  ^~~
   drivers/misc/cardreader/rtsx_usb.c:639:2: note: remove the 'if' if its condition is always false
           if (!ucr->rsp_buf)
           ^~~~~~~~~~~~~~~~~~
   drivers/misc/cardreader/rtsx_usb.c:622:9: note: initialize the variable 'ret' to silence this warning
           int ret;
                  ^
                   = 0

Fixes: 3776c78 ("misc: rtsx_usb: use separate command and response buffers")
Reported-by: kernel test robot <lkp@intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20220701165352.15687-1-skhan@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
shuahkh authored and gregkh committed Jul 12, 2022
1 parent ff79e0c commit ca4a919
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/misc/cardreader/rtsx_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,10 @@ static int rtsx_usb_probe(struct usb_interface *intf,
return -ENOMEM;

ucr->rsp_buf = kmalloc(IOBUF_SIZE, GFP_KERNEL);
if (!ucr->rsp_buf)
if (!ucr->rsp_buf) {
ret = -ENOMEM;
goto out_free_cmd_buf;
}

usb_set_intfdata(intf, ucr);

Expand Down

0 comments on commit ca4a919

Please sign in to comment.