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 CD7531946C8; Fri, 9 Jan 2026 12:02:06 +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=1767960126; cv=none; b=s5P5ACo0ML4W5AtqwIQN/BC9Caka9L/qFy7NSIkhEKMVFUm4RCY6lSfRXM29TW0uG0tDlb+2O68sNHO+5h5sc/b9v6JN0CmfPmWNgxSlwojyqF+wv937oel4DDZLco8fK09UXGmSvyRSMqTM4uap/oqK/LujJmUqQZyZIMT/xrg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767960126; c=relaxed/simple; bh=wwHFzI7MByfogAWWCDDmeZTKfMo6ro8vybiiCmilUOI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fr0tJFlpppRwVge/QBx1UkPm8U9ndcC/J6WUQWGMmTnRN7HGTOea3T68+zI/HONvGu0Qs7L2xNOJyaDy+iz7355BahNRxP6cMyVRdjCt69ITNsNhL4laPR4PhNChM0HiObTUWNTRLJPkO76xvP41HK9ILUrU6TYiAr8IJqd151I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YMo9szF8; 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="YMo9szF8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57975C4CEF1; Fri, 9 Jan 2026 12:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767960126; bh=wwHFzI7MByfogAWWCDDmeZTKfMo6ro8vybiiCmilUOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YMo9szF8Ishy3t/hzQA6AgSGLZvtoVNwqGICJ2MlIRZ98z5uh/969O9U8exVaAHmn +QlpN82sj+UGrod5KoHnjTz3riVU4MEizcqVcNwHzUABuhbp0b7jRX/6rkG+2QO0k0 +1wM9Y97pJ+y5WxdoIYS2nbCpQ/0u5FfrB9zvbbc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Diogo Ivo Subject: [PATCH 6.6 295/737] usb: phy: Initialize struct usb_phy list_head Date: Fri, 9 Jan 2026 12:37:14 +0100 Message-ID: <20260109112145.108140849@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260109112133.973195406@linuxfoundation.org> References: <20260109112133.973195406@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Diogo Ivo commit c69ff68b097b0f53333114f1b2c3dc128f389596 upstream. As part of the registration of a new 'struct usb_phy' with the USB PHY core via either usb_add_phy(struct usb_phy *x, ...) or usb_add_phy_dev(struct usb_phy *x) these functions call list_add_tail(&x->head, phy_list) in order for the new instance x to be stored in phy_list, a static list kept internally by the core. After 7d21114dc6a2 ("usb: phy: Introduce one extcon device into usb phy") when executing either of the registration functions above it is possible that usb_add_extcon() fails, leading to either function returning before the call to list_add_tail(), leaving x->head uninitialized. Then, when a driver tries to undo the failed registration by calling usb_remove_phy(struct usb_phy *x) there will be an unconditional call to list_del(&x->head) acting on an uninitialized variable, and thus a possible NULL pointer dereference. Fix this by initializing x->head before usb_add_extcon() has a chance to fail. Note that this was not needed before 7d21114dc6a2 since list_add_phy() was executed unconditionally and it guaranteed that x->head was initialized. Fixes: 7d21114dc6a2 ("usb: phy: Introduce one extcon device into usb phy") Cc: stable Signed-off-by: Diogo Ivo Link: https://patch.msgid.link/20251121-diogo-smaug_typec-v2-1-5c37c1169d57@tecnico.ulisboa.pt Signed-off-by: Greg Kroah-Hartman --- drivers/usb/phy/phy.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/usb/phy/phy.c +++ b/drivers/usb/phy/phy.c @@ -672,6 +672,8 @@ int usb_add_phy(struct usb_phy *x, enum return -EINVAL; } + INIT_LIST_HEAD(&x->head); + usb_charger_init(x); ret = usb_add_extcon(x); if (ret) @@ -722,6 +724,8 @@ int usb_add_phy_dev(struct usb_phy *x) return -EINVAL; } + INIT_LIST_HEAD(&x->head); + usb_charger_init(x); ret = usb_add_extcon(x); if (ret)