]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: gadget: u_serial: Avoid spinlock recursion in __gs_console_push
authorPrashanth K <quic_prashk@quicinc.com>
Tue, 9 May 2023 13:27:52 +0000 (18:57 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Aug 2023 12:23:23 +0000 (14:23 +0200)
commitcb174344bf85d29d3c53180ac75a55dfbb45a56e
tree7d3fc25673520cd000a746326a8e0facf9e1d851
parent1676748aa29099fc0abd71e0fb092e76e835f25c
usb: gadget: u_serial: Avoid spinlock recursion in __gs_console_push

[ Upstream commit e5990469943c711cb00bfde6338d2add6c6d0bfe ]

When serial console over USB is enabled, gs_console_connect
queues gs_console_work, where it acquires the spinlock and
queues the usb request, and this request goes to gadget layer.
Now consider a situation where gadget layer prints something
to dmesg, this will eventually call gs_console_write() which
requires cons->lock. And this causes spinlock recursion. Avoid
this by excluding usb_ep_queue from the spinlock.

 spin_lock_irqsave //needs cons->lock
 gs_console_write
.
.
 _printk
 __warn_printk
 dev_warn/pr_err
.
.
 [USB Gadget Layer]
.
.
 usb_ep_queue
 gs_console_work
 __gs_console_push // acquires cons->lock
 process_one_work

Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
Link: https://lore.kernel.org/r/1683638872-6885-1-git-send-email-quic_prashk@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/gadget/function/u_serial.c