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 C22723C0099; Thu, 15 Jan 2026 17:46:57 +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=1768499217; cv=none; b=aLYUsZlXEyT7Sd/28grpuJQMK3WsQCTiYd26Q18825sSgzroSiTNZczNY91H/718du3YATdtqyL/LlH0AQT/1ZLXCJLWr4uIlxCD/AgojCD8waAq4U0RpF/czGgNx1TCuKV55x3kvArfMxb+OCPZtrBq9qtdh9HCTV4Ml/yOOho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768499217; c=relaxed/simple; bh=2DhvskFPTP4FV8KEnwo5AA4f2acj402fkpFKAbT8XSA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BtR8I6LvEwjYnHaSAUnzn3EIPvpf9dVgmdEbuDkCbA0Uji0tIpKfnjDFjkCjJAyEawOHecMG/fBQezs5mAzyLCvLLHImA/PCCSDpxbsZNXEsxKRj0lWi9b2wVIoTv5bnOuTxAJsqPYl9sMBOjWPPWtd/4r5ehAA58rpvcNXCgII= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XBiM1GJa; 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="XBiM1GJa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FB31C16AAE; Thu, 15 Jan 2026 17:46:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1768499217; bh=2DhvskFPTP4FV8KEnwo5AA4f2acj402fkpFKAbT8XSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XBiM1GJaEnyfzRmL1uuy8vjU/EtJexIxqwDCPa3sSZmaU4bHV1XszlWFElKx/LbHW yb84S1t167eLvS11pLDezM34KcaVdUfySpzH4Le5DWY4k0s+gM3V9rFvgwbXn540uc 6JpDR31vClGNlqyhB0jwFFSqxsq6uFVrUd4E3zPo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Diogo Ivo Subject: [PATCH 5.10 149/451] usb: phy: Initialize struct usb_phy list_head Date: Thu, 15 Jan 2026 17:45:50 +0100 Message-ID: <20260115164236.305801572@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115164230.864985076@linuxfoundation.org> References: <20260115164230.864985076@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 5.10-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 @@ -634,6 +634,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) @@ -679,6 +681,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)