]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hwmon: (powerz) Fix use-after-free on USB disconnect
authorSanman Pradhan <psanman@juniper.net>
Fri, 10 Apr 2026 00:25:35 +0000 (00:25 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Apr 2026 11:22:32 +0000 (13:22 +0200)
commit9e1b798257f96d2e2a2639830eb71add545ce749
treeecae7548fb84e3e5c96c02decb1403b6fc01be96
parent871b8ea8ef39a6c253594649f4339378fad3d0dd
hwmon: (powerz) Fix use-after-free on USB disconnect

commit 08e57f5e1a9067d5fbf33993aa7f51d60b3d13a4 upstream.

After powerz_disconnect() frees the URB and releases the mutex, a
subsequent powerz_read() call can acquire the mutex and call
powerz_read_data(), which dereferences the freed URB pointer.

Fix by:
 - Setting priv->urb to NULL in powerz_disconnect() so that
   powerz_read_data() can detect the disconnected state.
 - Adding a !priv->urb check at the start of powerz_read_data()
   to return -ENODEV on a disconnected device.
 - Moving usb_set_intfdata() before hwmon registration so the
   disconnect handler can always find the priv pointer.

Fixes: 4381a36abdf1c ("hwmon: add POWER-Z driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sanman Pradhan <psanman@juniper.net>
Link: https://lore.kernel.org/r/20260410002521.422645-2-sanman.pradhan@hpe.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwmon/powerz.c