[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250108174224.23096-1-dpenkler@gmail.com>
Date: Wed, 8 Jan 2025 18:42:24 +0100
From: Dave Penkler <dpenkler@...il.com>
To: gregkh@...uxfoundation.org,
linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org
Cc: Dave Penkler <dpenkler@...il.com>,
kernel test robot <lkp@...el.com>,
Dan Carpenter <dan.carpenter@...aro.org>
Subject: [PATCH v2] staging: gpib: Add missing mutex unlock on early return in
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@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
Closes: https://lore.kernel.org/r/202412201550.9NCO57Ye-lkp@intel.com/
Signed-off-by: Dave Penkler <dpenkler@...il.com>
---
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
Powered by blists - more mailing lists