From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796354730; b=NlYOtM9BQPwn0QsVh3XCv96XL90VXd/Pz6wVNtswwghZ271fuHO0RkHBVvQHmUM0hBGM p8XrAnBnUE8CL+PA70cQRe544eUc99a/WtvBXTI5X/VTvMnF5SbdQuS5EiVpv7fl9GOn8 gdiwCaC3MnJgEavoqe0fcs89cHmPnRj+qar/OIbzGIlmj5kIa0c8L4/zxSNbl68l8jUTr FsE1/GglxLWrzde8L6GVGnTgqHr+HuElOONQ9dta5MqSYCCK2osiYzMFgJjeWNMPlYYTq PcmeMPWFaCHxZE4OVWR/WEbnmpSrugnUSptUB80ddUJdGZcVgkj9HCGSbhurtxGPykA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796354730; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=hbciqH72CEz0qS17B5eMyOri3CJJhqKhG+kysE5jCRU=; b=PFpfbMrcOLUc9FUNtvlJjekXz4EAl+geXsKmhGZud/8tGg0k0J8emDF8RrMiKO/eJGTQ CAaIF2ItPuFcCibXRSVHeEE7pjMqfv1BUhZ+CPgqj7tXh4OQS5llDAIYGDhQ0DVGa8Lxx V+xOEjja5rxtdVvvnOySZYxPOX/lGV2aZTussNoukgoYpKr+p8J5KuZSS2Mxhe3CLOmFl 15Q56NXBC1G232dxgJEZMYaxIhA2W2vcYlHPKnWmpEW+n6a8O2huEIxaRFKxgL8JV9iWA /jfJBdz8spj7wV+aOkxx+UfWfU1LrvX4G1/i5fLAxyNsgWk4QKs4b4GcQkntv05EG4g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JVcuG7uO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AE2A606A32C; Fri, 4 Dec 2026 03:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JVcuG7uO Received: by smtp.kernel.org (Postfix) with ESMTPSA id D218F1F00933; Fri, 4 Dec 2026 03:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796354730; bh=hbciqH72CEz0qS17B5eMyOri3CJJhqKhG+kysE5jCRU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=JVcuG7uOXu+4Dv4BZBI432VshSGE7APzW4qkMmRzQZPN7sGpZ5+YEmGk4/hvNqg9d YpdDmvp0pk+C2/TUaYnEL1ZWb31hqvO6N6fkyhka4OWJcWxgcNcg4sQoUg2vcrwt6r NSgwZiHkkuvYFOp+0fiS7hyWu+6NsFckhd/qybso= Date: Thu, 3 Dec 2026 20:09:48 +0100 From: Greg KH To: "Bin Luo (University of Electronic Science and Technology of China)" Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] usb: phy: twl6030: initialize lock and work before registering comparator Message-ID: <2026120337-pyramid-spending-42a4@gregkh> References: <20261127133923.1452-1-luob87709@gmail.com> <20261127133923.1452-2-luob87709@gmail.com> X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261127133923.1452-2-luob87709@gmail.com> On Fri, Nov 27, 2026 at 09:39:22PM +0800, Bin Luo (University of Electronic Science and Technology of China) wrote: > twl6030_usb_probe() publishes &twl->comparator via > omap_usb2_set_comparator() before initializing twl->lock, > twl->set_vbus_work, and twl->get_status_work. If the OMAP USB2 PHY > invokes twl6030_set_vbus() in that window, schedule_work() operates on > an uninitialized work_struct. > > Initialize twl->lock and the work items before calling > omap_usb2_set_comparator(). > > Found by static code audit. > > Fixes: 0e98de67bacb ("usb: otg: make twl6030_usb as a comparator driver to omap_usb2") > Signed-off-by: Bin Luo (University of Electronic Science and Technology of China) > --- > drivers/usb/phy/phy-twl6030-usb.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c > index 9bfcb2c..b28a94b 100644 > --- a/drivers/usb/phy/phy-twl6030-usb.c > +++ b/drivers/usb/phy/phy-twl6030-usb.c > @@ -355,15 +355,16 @@ static int twl6030_usb_probe(struct platform_device *pdev) > twl->comparator.set_vbus = twl6030_set_vbus; > twl->comparator.start_srp = twl6030_start_srp; > > + spin_lock_init(&twl->lock); > + INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work); > + INIT_DELAYED_WORK(&twl->get_status_work, twl6030_status_work); > + > ret = omap_usb2_set_comparator(&twl->comparator); > if (ret == -ENODEV) { > dev_info(&pdev->dev, "phy not ready, deferring probe"); > return -EPROBE_DEFER; > } > > - /* init spinlock for workqueue */ > - spin_lock_init(&twl->lock); > - > err = twl6030_usb_ldo_init(twl); > if (err) { > dev_err(&pdev->dev, "ldo init failed\n"); > @@ -372,9 +373,6 @@ static int twl6030_usb_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, twl); > > - INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work); > - INIT_DELAYED_WORK(&twl->get_status_work, twl6030_status_work); > - > status = request_threaded_irq(twl->irq1, NULL, twl6030_usbotg_irq, > IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_ONESHOT, > "twl6030_usb", twl); > -- > 2.51.0.windows.1 > > Please test on the real hardware first.