When the buffer allocation for return data in ni_usb_write() fails we were returning without unlocking the addressed_transfer_lock. Add the unlock call. This was detected by smatch: New smatch warnings: drivers/staging/gpib/ni_usb/ni_usb_gpib.c:837 ni_usb_write() warn: inconsistent returns '&ni_priv->addressed_transfer_lock'. Reported-by: kernel test robot <lkp@xxxxxxxxx> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Closes: https://lore.kernel.org/r/202412201550.9NCO57Ye-lkp@xxxxxxxxx/ Signed-off-by: Dave Penkler <dpenkler@xxxxxxxxx> --- drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/gpib/ni_usb/ni_usb_gpib.c b/drivers/staging/gpib/ni_usb/ni_usb_gpib.c index 2c0a0d7e36c6..d0656dc520f5 100644 --- a/drivers/staging/gpib/ni_usb/ni_usb_gpib.c +++ b/drivers/staging/gpib/ni_usb/ni_usb_gpib.c @@ -783,8 +783,10 @@ static int ni_usb_write(gpib_board_t *board, uint8_t *buffer, size_t length, } in_data = kmalloc(in_data_length, GFP_KERNEL); - if (!in_data) + if (!in_data) { + mutex_unlock(&ni_priv->addressed_transfer_lock); return -ENOMEM; + } retval = ni_usb_receive_bulk_msg(ni_priv, in_data, in_data_length, &usb_bytes_read, ni_usb_timeout_msecs(board->usec_timeout), 1); -- 2.47.1