linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] usb: common: ulpi: Fix crash in ulpi_match()
@ 2022-01-17 15:00 Jon Hunter
  2022-01-17 15:40 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Jon Hunter @ 2022-01-17 15:00 UTC (permalink / raw)
  To: Heikki Krogerus, Stephan Gerhold, Andy Gross, Bjorn Andersson
  Cc: linux-usb, linux-kernel, linux-tegra, Jon Hunter

Commit 7495af930835 ("ARM: multi_v7_defconfig: Enable drivers for
DragonBoard 410c") enables the CONFIG_PHY_QCOM_USB_HS for the ARM
multi_v7_defconfig. Enabling this Kconfig is causing the kernel to crash
on the Tegra20 Ventana platform in the ulpi_match() function.

The Qualcomm USB HS PHY driver that is enabled by CONFIG_PHY_QCOM_USB_HS,
registers a ulpi_driver but this driver does not provide an 'id_table',
so when ulpi_match() is called on the Tegra20 Ventana platform, it
crashes when attempting to deference the id_table pointer which is not
valid. The Qualcomm USB HS PHY driver uses device-tree for matching the
ULPI driver with the device and so fix this crash by using device-tree
for matching if the id_table is not valid.

Fixes: ef6a7bcfb01c ("usb: ulpi: Support device discovery via DT")
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
Changes since V1:
- Added fixes tag

 drivers/usb/common/ulpi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
index 4169cf40a03b..8f8405b0d608 100644
--- a/drivers/usb/common/ulpi.c
+++ b/drivers/usb/common/ulpi.c
@@ -39,8 +39,11 @@ static int ulpi_match(struct device *dev, struct device_driver *driver)
 	struct ulpi *ulpi = to_ulpi_dev(dev);
 	const struct ulpi_device_id *id;
 
-	/* Some ULPI devices don't have a vendor id so rely on OF match */
-	if (ulpi->id.vendor == 0)
+	/*
+	 * Some ULPI devices don't have a vendor id
+	 * or provide an id_table so rely on OF match.
+	 */
+	if (ulpi->id.vendor == 0 || !drv->id_table)
 		return of_driver_match_device(dev, driver);
 
 	for (id = drv->id_table; id->vendor; id++)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] usb: common: ulpi: Fix crash in ulpi_match()
  2022-01-17 15:00 [PATCH V2] usb: common: ulpi: Fix crash in ulpi_match() Jon Hunter
@ 2022-01-17 15:40 ` Greg KH
  2022-01-18  9:02   ` Jon Hunter
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2022-01-17 15:40 UTC (permalink / raw)
  To: Jon Hunter
  Cc: Heikki Krogerus, Stephan Gerhold, Andy Gross, Bjorn Andersson,
	linux-usb, linux-kernel, linux-tegra

On Mon, Jan 17, 2022 at 03:00:39PM +0000, Jon Hunter wrote:
> Commit 7495af930835 ("ARM: multi_v7_defconfig: Enable drivers for
> DragonBoard 410c") enables the CONFIG_PHY_QCOM_USB_HS for the ARM
> multi_v7_defconfig. Enabling this Kconfig is causing the kernel to crash
> on the Tegra20 Ventana platform in the ulpi_match() function.
> 
> The Qualcomm USB HS PHY driver that is enabled by CONFIG_PHY_QCOM_USB_HS,
> registers a ulpi_driver but this driver does not provide an 'id_table',
> so when ulpi_match() is called on the Tegra20 Ventana platform, it
> crashes when attempting to deference the id_table pointer which is not
> valid. The Qualcomm USB HS PHY driver uses device-tree for matching the
> ULPI driver with the device and so fix this crash by using device-tree
> for matching if the id_table is not valid.
> 
> Fixes: ef6a7bcfb01c ("usb: ulpi: Support device discovery via DT")
> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>

No cc: of stable since this is a bug going back to 4.11?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] usb: common: ulpi: Fix crash in ulpi_match()
  2022-01-17 15:40 ` Greg KH
@ 2022-01-18  9:02   ` Jon Hunter
  2022-01-18  9:16     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Jon Hunter @ 2022-01-18  9:02 UTC (permalink / raw)
  To: Greg KH
  Cc: Heikki Krogerus, Stephan Gerhold, Andy Gross, Bjorn Andersson,
	linux-usb, linux-kernel, linux-tegra


On 17/01/2022 15:40, Greg KH wrote:
> On Mon, Jan 17, 2022 at 03:00:39PM +0000, Jon Hunter wrote:
>> Commit 7495af930835 ("ARM: multi_v7_defconfig: Enable drivers for
>> DragonBoard 410c") enables the CONFIG_PHY_QCOM_USB_HS for the ARM
>> multi_v7_defconfig. Enabling this Kconfig is causing the kernel to crash
>> on the Tegra20 Ventana platform in the ulpi_match() function.
>>
>> The Qualcomm USB HS PHY driver that is enabled by CONFIG_PHY_QCOM_USB_HS,
>> registers a ulpi_driver but this driver does not provide an 'id_table',
>> so when ulpi_match() is called on the Tegra20 Ventana platform, it
>> crashes when attempting to deference the id_table pointer which is not
>> valid. The Qualcomm USB HS PHY driver uses device-tree for matching the
>> ULPI driver with the device and so fix this crash by using device-tree
>> for matching if the id_table is not valid.
>>
>> Fixes: ef6a7bcfb01c ("usb: ulpi: Support device discovery via DT")
>> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> 
> No cc: of stable since this is a bug going back to 4.11?


Yes good point.

Heikki, let me know if you want me to resend or if you can add the 
stable tag?

Cheers
Jon

-- 
nvpublic

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] usb: common: ulpi: Fix crash in ulpi_match()
  2022-01-18  9:02   ` Jon Hunter
@ 2022-01-18  9:16     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2022-01-18  9:16 UTC (permalink / raw)
  To: Jon Hunter
  Cc: Heikki Krogerus, Stephan Gerhold, Andy Gross, Bjorn Andersson,
	linux-usb, linux-kernel, linux-tegra

On Tue, Jan 18, 2022 at 09:02:36AM +0000, Jon Hunter wrote:
> 
> On 17/01/2022 15:40, Greg KH wrote:
> > On Mon, Jan 17, 2022 at 03:00:39PM +0000, Jon Hunter wrote:
> > > Commit 7495af930835 ("ARM: multi_v7_defconfig: Enable drivers for
> > > DragonBoard 410c") enables the CONFIG_PHY_QCOM_USB_HS for the ARM
> > > multi_v7_defconfig. Enabling this Kconfig is causing the kernel to crash
> > > on the Tegra20 Ventana platform in the ulpi_match() function.
> > > 
> > > The Qualcomm USB HS PHY driver that is enabled by CONFIG_PHY_QCOM_USB_HS,
> > > registers a ulpi_driver but this driver does not provide an 'id_table',
> > > so when ulpi_match() is called on the Tegra20 Ventana platform, it
> > > crashes when attempting to deference the id_table pointer which is not
> > > valid. The Qualcomm USB HS PHY driver uses device-tree for matching the
> > > ULPI driver with the device and so fix this crash by using device-tree
> > > for matching if the id_table is not valid.
> > > 
> > > Fixes: ef6a7bcfb01c ("usb: ulpi: Support device discovery via DT")
> > > Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> > 
> > No cc: of stable since this is a bug going back to 4.11?
> 
> 
> Yes good point.
> 
> Heikki, let me know if you want me to resend or if you can add the stable
> tag?

I can add it myself.  I'll do so after 5.17-rc1 is out, when I can apply
things to my tree.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-18  9:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-17 15:00 [PATCH V2] usb: common: ulpi: Fix crash in ulpi_match() Jon Hunter
2022-01-17 15:40 ` Greg KH
2022-01-18  9:02   ` Jon Hunter
2022-01-18  9:16     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).