Skip to contentSkip to conversation

USB: make hcd->irq signed for error handling

PATCH In review Dan Carpenter 2 participants 2 messages Nov 7, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: make hcd->irq signed for error handling

There is a bug in ehci_msm_probe() where we do:

	hcd->irq = platform_get_irq(pdev, 0);
	if (hcd->irq < 0) {

The problem is that hcd->irq is unsigned so the error handling doesn't work. I have made it signed.

include/linux/usb/hcd.h +1 -1
index b8aba19..95be4a0 100644
@@ -143,7 +143,7 @@ struct usb_hcd {
 	unsigned		has_tt:1;	/* Integrated TT in root hub */
 	unsigned		amd_resume_bug:1; /* AMD remote wakeup quirk */
 
-	unsigned int		irq;		/* irq allocated */
+	int			irq;		/* irq allocated */
 	void __iomem		*regs;		/* device memory/io */
 	resource_size_t		rsrc_start;	/* memory/io resource start */
 	resource_size_t		rsrc_len;	/* memory/io resource length */
#1 lore raw
Quoted 15 lines · Dan Carpenter

There is a bug in ehci_msm_probe() where we do:

	hcd->irq = platform_get_irq(pdev, 0);
	if (hcd->irq < 0) {

The problem is that hcd->irq is unsigned so the error handling doesn't work. I have made it signed.

include/linux/usb/hcd.h +0 -0
index b8aba19..95be4a0 100644

include/linux/usb/hcd.h struct usb_hcd { · line 149

Quoted 8 lines
include/linux/usb/hcd.h +1 -1
@@ -143,7 +143,7 @@ struct usb_hcd {
 	unsigned		has_tt:1;	/* Integrated TT in root hub */
 	unsigned		amd_resume_bug:1; /* AMD remote wakeup quirk */
 
-	unsigned int		irq;		/* irq allocated */
+	int			irq;		/* irq allocated */
 	void __iomem		*regs;		/* device memory/io */
 	resource_size_t		rsrc_start;	/* memory/io resource start */
 	resource_size_t		rsrc_len;	/* memory/io resource length */

The .irq member of struct pci_dev is also unsigned int. I suspect we shouldn't break with tradition. Besides, if you're going to change this then you really ought to change the second parameter of usb_hcd_request_irqs().

Why not simply fix ehci_msm_probe() instead? And while you're at it, do the same thing for ehci_hcd_tilegx_drv_probe() and ohci_hcd_tilegx_drv_probe().

Alan Stern