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 <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/202412201550.9NCO57Ye-lkp@intel.com/ Signed-off-by: Dave Penkler <dpenkler@gmail.com> Link: https://lore.kernel.org/r/20250111161548.27601-1-dpenkler@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 55eb3c3 commit d43f18d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

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)