Skip to contentSkip to conversation

usb/hcd: Fix a NULL vs IS_ERR() bug in usb_hcd_setup_local_mem()

PATCH In review Dan Carpenter 2 participants 2 messages Jun 7, 2019 – Jun 11, 2019

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

PATCH 1/1 usb/hcd: Fix a NULL vs IS_ERR() bug in usb_hcd_setup_local_mem()

The devm_memremap() function doesn't return NULL, it returns error pointers.

Fixes b0310c2f09bb ("USB: use genalloc for USB HCs with local memory")
---
 drivers/usb/core/hcd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/core/hcd.c +2 -2
index fe631d18c1ed..df8f358685e6 100644
@@ -3052,8 +3052,8 @@ int usb_hcd_setup_local_mem(struct usb_hcd *hcd, phys_addr_t phys_addr,
 
 	local_mem = devm_memremap(hcd->self.sysdev, phys_addr,
 				  size, MEMREMAP_WC);
-	if (!local_mem)
-		return -ENOMEM;
+	if (IS_ERR(local_mem))
+		return PTR_ERR(local_mem);
 
 	/*
 	 * Here we pass a dma_addr_t but the arg type is a phys_addr_t.
Signature · 1 line
2.20.1