[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250220120314.3614330-1-m.szyprowski@samsung.com>
Date: Thu, 20 Feb 2025 13:03:14 +0100
From: Marek Szyprowski <m.szyprowski@...sung.com>
To: linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Marek Szyprowski <m.szyprowski@...sung.com>, Greg Kroah-Hartman
<gregkh@...uxfoundation.org>, Prashanth K <prashanth.k@....qualcomm.com>,
stable <stable@...nel.org>
Subject: [PATCH] usb: gadget: Fix setting self-powered state on suspend
cdev->config might be NULL, so check it before dereferencing.
CC: stable <stable@...nel.org>
Fixes: 40e89ff5750f ("usb: gadget: Set self-powered based on MaxPower and bmAttributes")
Signed-off-by: Marek Szyprowski <m.szyprowski@...sung.com>
---
This fixes the following kernel panic introduced by today's linux-next (next-20250220):
g_ether gadget.0: HOST MAC fa:78:4e:a7:95:93
g_ether gadget.0: MAC ee:49:25:cd:df:9f
g_ether gadget.0: Ethernet Gadget, version: Memorial Day 2008
g_ether gadget.0: g_ether ready
Unable to handle kernel NULL pointer dereference at virtual address 000000000000002a
Mem abort info:
ESR = 0x0000000096000004
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x04: level 0 translation fault
dwmmc_exynos 12100000.mmc: Unexpected interrupt latency
Data abort info:
ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
CM = 0, WnR = 0, TnD = 0, TagAccess = 0
GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
user pgtable: 4k pages, 48-bit VAs, pgdp=0000000887099000
[000000000000002a] pgd=0000000000000000, p4d=0000000000000000
Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
Modules linked in: phy_exynos5_usbdrd typec ramoops reed_solomon fuse dm_mod ip_tables x_tables ipv6
CPU: 0 UID: 0 PID: 219 Comm: irq/91-dwc3 Not tainted 6.14.0-rc3-next-20250220+ #9824
Hardware name: WinLink E850-96 board (DT)
pstate: 604000c5 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : composite_suspend+0x88/0xd8
lr : dwc3_suspend_gadget+0x44/0x5c
...
Call trace:
composite_suspend+0x88/0xd8 (P)
dwc3_suspend_gadget+0x44/0x5c
dwc3_thread_interrupt+0x934/0xbf0
irq_thread_fn+0x2c/0xa8
irq_thread+0x194/0x358
kthread+0x13c/0x214
ret_from_fork+0x10/0x20
Code: f9400e83 39450680 321f0000 39050680 (3940a860)
---[ end trace 0000000000000000 ]---
Kernel panic - not syncing: Oops: Fatal exception in interrupt
SMP: stopping secondary CPUs
Kernel Offset: disabled
CPU features: 0x100,00000000,00801250,0200720b
Memory Limit: none
---[ end Kernel panic - not syncing: Oops: Fatal exception in interrupt ]---
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
---
drivers/usb/gadget/composite.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 1fb28bbf6c45..4bcf73bae761 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -2616,7 +2616,8 @@ void composite_suspend(struct usb_gadget *gadget)
cdev->suspended = 1;
- if (cdev->config->bmAttributes & USB_CONFIG_ATT_SELFPOWER)
+ if (cdev->config &&
+ cdev->config->bmAttributes & USB_CONFIG_ATT_SELFPOWER)
usb_gadget_set_selfpowered(gadget);
usb_gadget_vbus_draw(gadget, 2);
--
2.34.1
Powered by blists - more mailing lists