Skip to content

Commit d43f18d

Browse files
dpenklergregkh
authored andcommitted
staging: gpib: Add missing mutex unlock in ni usb driver
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 <[email protected]> Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Signed-off-by: Dave Penkler <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 55eb3c3 commit d43f18d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/staging/gpib/ni_usb/ni_usb_gpib.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,10 @@ static int ni_usb_write(gpib_board_t *board, uint8_t *buffer, size_t length,
783783
}
784784

785785
in_data = kmalloc(in_data_length, GFP_KERNEL);
786-
if (!in_data)
786+
if (!in_data) {
787+
mutex_unlock(&ni_priv->addressed_transfer_lock);
787788
return -ENOMEM;
789+
}
788790
retval = ni_usb_receive_bulk_msg(ni_priv, in_data, in_data_length, &usb_bytes_read,
789791
ni_usb_timeout_msecs(board->usec_timeout), 1);
790792

0 commit comments

Comments
 (0)