usb/hcd: Fix a NULL vs IS_ERR() bug in usb_hcd_setup_local_mem()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 7 Jun 2019 13:57:09 +0000 (16:57 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jul 2019 08:40:02 +0000 (10:40 +0200)
The devm_memremap() function doesn't return NULL, it returns error
pointers.

Fixes: b0310c2f09bb ("USB: use genalloc for USB HCs with local memory")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20190607135709.GC16718@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/hcd.c

index 88533938ce19512aa5cdeaa2469721b39560d063..9320787ac2e648cb7a8c319b8b56f2e95623ff9b 100644 (file)
@@ -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.