Skip to contentSkip to conversation

usb: host: iounmap before return

PATCH Superseded Geyslan G. Bem 3 participants 5 messages Dec 6, 2015 – Dec 7, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: host: iounmap before return

This patch fixes a 'quirk_usb_handoff_xhci()' branch return that was not unmapping correctly.

Coccinelle: scripts/coccinelle/free/iounmap.cocci

---
 drivers/usb/host/pci-quirks.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/host/pci-quirks.c +2 -1
index f940056..64150dd 100644
@@ -990,7 +990,7 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
 			/* We're reading garbage from the controller */
 			dev_warn(&pdev->dev,
 				 "xHCI controller failing to respond");
-			return;
+			goto out;
 		}
 
 		if (!ext_cap_offset)
@@ -1062,6 +1062,7 @@ hc_init:
 			 XHCI_MAX_HALT_USEC, val);
 	}
 
+out:
 	iounmap(base);
 }
 
Signature · 1 line
2.6.3
#1 lore raw
Quoted 14 lines · Geyslan G. Bem

This patch fixes a 'quirk_usb_handoff_xhci()' branch return that was not unmapping correctly.

Coccinelle: scripts/coccinelle/free/iounmap.cocci

---
 drivers/usb/host/pci-quirks.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/host/pci-quirks.c +0 -0
index f940056..64150dd 100644

drivers/usb/host/pci-quirks.c static void quirk_usb_handoff_xhci(struct pci_dev *pdev) · line 993

Quoted 5 lines
drivers/usb/host/pci-quirks.c +1 -1
@@ -990,7 +990,7 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
 			/* We're reading garbage from the controller */
 			dev_warn(&pdev->dev,
 				 "xHCI controller failing to respond");
-			return;
+			goto out;

If "out" is only used here, why not iounmap and return directly here?

Quoted 11 lines
drivers/usb/host/pci-quirks.c +1 -0
 		}
 
 		if (!ext_cap_offset)
@@ -1062,6 +1062,7 @@ hc_init:
 			 XHCI_MAX_HALT_USEC, val);
 	}
 
+out:
 	iounmap(base);
 }
 
#2 lore raw

2015-12-07 6:30 GMT-03:00 Lu Baolu <[email protected]>:

Quoted 12 lines · Geyslan G. Bem
Quoted 9 lines

This patch fixes a 'quirk_usb_handoff_xhci()' branch return that was not unmapping correctly.

Coccinelle: scripts/coccinelle/free/iounmap.cocci

---
 drivers/usb/host/pci-quirks.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines

drivers/usb/host/pci-quirks.c static void quirk_usb_handoff_xhci(struct pci_dev *pdev) · line 993

Quoted 10 lines
drivers/usb/host/pci-quirks.c +1 -1
index f940056..64150dd 100644
@@ -990,7 +990,7 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
                      /* We're reading garbage from the controller */
                      dev_warn(&pdev->dev,
                               "xHCI controller failing to respond");
-                     return;
+                     goto out;

If "out" is only used here, why not iounmap and return directly here?

Could be directly. I just think that code recurrence can make things complicated in future. What do you think?

Ah, seems that this patch is not aligned with linux-next. I'll make a new one soon.

Quoted 13 lines
Quoted 12 lines
drivers/usb/host/pci-quirks.c +1 -0
              }
 
              if (!ext_cap_offset)
@@ -1062,6 +1062,7 @@ hc_init:
                       XHCI_MAX_HALT_USEC, val);
      }
 
+out:
      iounmap(base);
 }
 
Signature · 4 lines
Regards,

Geyslan G. Bem
hackingbits.com
#3 lore raw
In reply to Lu Baolu

Hello.

Quoted 9 lines · Lu Baolu
Quoted 9 lines

This patch fixes a 'quirk_usb_handoff_xhci()' branch return that was not unmapping correctly.

Coccinelle: scripts/coccinelle/free/iounmap.cocci

---
  drivers/usb/host/pci-quirks.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines

drivers/usb/host/pci-quirks.c static void quirk_usb_handoff_xhci(struct pci_dev *pdev) · line 993

Quoted 10 lines
drivers/usb/host/pci-quirks.c +1 -1
index f940056..64150dd 100644
@@ -990,7 +990,7 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
  			/* We're reading garbage from the controller */
  			dev_warn(&pdev->dev,
  				 "xHCI controller failing to respond");
-			return;
+			goto out;

If "out" is only used here, why not iounmap and return directly here?

Why repeat the code? Nah, bad idea.

Quoted 11 lines

drivers/usb/host/pci-quirks.c hc_init: · line 1068

Quoted 11 lines
drivers/usb/host/pci-quirks.c +1 -0
  		}
 
  		if (!ext_cap_offset)
@@ -1062,6 +1062,7 @@ hc_init:
  			 XHCI_MAX_HALT_USEC, val);
  	}
 
+out:
  	iounmap(base);
  }
 

MBR, Sergei

#4 lore raw

2015-12-07 8:37 GMT-03:00 Sergei Shtylyov <[email protected]>:

Quoted 40 lines

Hello.

Quoted 10 lines · Lu Baolu
Quoted 10 lines

This patch fixes a 'quirk_usb_handoff_xhci()' branch return that was not unmapping correctly.

Coccinelle: scripts/coccinelle/free/iounmap.cocci

---
  drivers/usb/host/pci-quirks.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 15 lines

drivers/usb/host/pci-quirks.c static void quirk_usb_handoff_xhci(struct pci_dev · line 994

Quoted 12 lines
drivers/usb/host/pci-quirks.c +1 -1
index f940056..64150dd 100644
@@ -990,7 +990,7 @@ static void quirk_usb_handoff_xhci(struct pci_dev
 *pdev)
                        /* We're reading garbage from the controller */
                        dev_warn(&pdev->dev,
                                 "xHCI controller failing to respond");
-                       return;
+                       goto out;

If "out" is only used here, why not iounmap and return directly here?

Why repeat the code? Nah, bad idea.

Quoted 7 lines
Quoted 7 lines
drivers/usb/host/pci-quirks.c +0 -0
                }
 

if (!ext_cap_offset)

drivers/usb/host/pci-quirks.c +0 -0
@@ -1062,6 +1062,7 @@ hc_init:
                         XHCI_MAX_HALT_USEC, val);
        }
 
Quoted 7 lines
Quoted 4 lines

drivers/usb/host/pci-quirks.c hc_init: · line 1068

Quoted 4 lines
drivers/usb/host/pci-quirks.c +1 -0
+out:
        iounmap(base);
  }
 

MBR, Sergei

Look for:
[PATCH v2] usb: host: iounmap before return

Signature · 4 lines
Regards,

Geyslan G. Bem
hackingbits.com