From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BF633321AA; Mon, 20 Apr 2026 15:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776700581; cv=none; b=PadtYL6Mx+dArscqT80eD4WQNlMWK4d4Uu1mPnSvK2kZHfF6nKAoQfh9BF+SLvpdRrFwm4OnXxpRayoZqZ66yCgWVbVLx/v+3jBja7HXhg+kXlKqVFg3a49t+0CyFUJtFbHL5Hh9N1kfBSuQe2ANaTYSUOovoPFnJbkLxDeGoz0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776700581; c=relaxed/simple; bh=rHc+Ge6fdv1IZeVsq9cegwzb+RmrjQcdNkfS6KluaoQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BBITuSKxxm4vFlQujdb5tzy89JnNGid9dOksp9l3FFSDRZ+cYnbVf7DP/T7rPT+dYCix9e0KTSSbvCIAqq8XY6vtg6afi+CfGHgRA92dWckt1iockhFZ1qH7ydcRClO090prOfCLODYlhpzdXqA/YWW8XY4E2bdYWXWZj0HE+8s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dWadmnei; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="dWadmnei" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 240A4C19425; Mon, 20 Apr 2026 15:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776700581; bh=rHc+Ge6fdv1IZeVsq9cegwzb+RmrjQcdNkfS6KluaoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dWadmneiS+ygFLSIvqU9a7Scqa88WY5xgshfJl+YwSpgKj8ZrDyJhnJVrwaJJDBmo KucVB0yYhZUzavrbsBDxMtLbgOBqx/16AZJdeP2VnaZcl8E6t6ql7IrB5XAtzgIv5Y KOqlflPkpAwILCm0cyysd9BNqeHSDix0pw4JiIos= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sanman Pradhan , Guenter Roeck Subject: [PATCH 6.19 210/220] hwmon: (powerz) Fix use-after-free on USB disconnect Date: Mon, 20 Apr 2026 17:42:31 +0200 Message-ID: <20260420153941.588854268@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260420153934.013228280@linuxfoundation.org> References: <20260420153934.013228280@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sanman Pradhan 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 Link: https://lore.kernel.org/r/20260410002521.422645-2-sanman.pradhan@hpe.com Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/powerz.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/hwmon/powerz.c +++ b/drivers/hwmon/powerz.c @@ -108,6 +108,9 @@ static int powerz_read_data(struct usb_d { int ret; + if (!priv->urb) + return -ENODEV; + priv->status = -ETIMEDOUT; reinit_completion(&priv->completion); @@ -224,6 +227,8 @@ static int powerz_probe(struct usb_inter mutex_init(&priv->mutex); init_completion(&priv->completion); + usb_set_intfdata(intf, priv); + hwmon_dev = devm_hwmon_device_register_with_info(parent, DRIVER_NAME, priv, &powerz_chip_info, NULL); @@ -232,8 +237,6 @@ static int powerz_probe(struct usb_inter return PTR_ERR(hwmon_dev); } - usb_set_intfdata(intf, priv); - return 0; } @@ -244,6 +247,7 @@ static void powerz_disconnect(struct usb mutex_lock(&priv->mutex); usb_kill_urb(priv->urb); usb_free_urb(priv->urb); + priv->urb = NULL; mutex_unlock(&priv->mutex); }