isdn: mISDNinfineon: fix potential NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Sat, 9 Mar 2019 05:49:34 +0000 (23:49 -0600)
committerDavid S. Miller <davem@davemloft.net>
Sun, 10 Mar 2019 17:58:08 +0000 (10:58 -0700)
In case ioremap fails, the fix returns -ENOMEM to avoid NULL
pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/isdn/hardware/mISDN/mISDNinfineon.c

index 3e01012be4abc3a8abe51d727ad1fe70b83badd7..0fe6ddcb3fdcf7c615e1a3acb760438bc94154c4 100644 (file)
@@ -712,8 +712,11 @@ setup_io(struct inf_hw *hw)
                                (ulong)hw->addr.start, (ulong)hw->addr.size);
                        return err;
                }
-               if (hw->ci->addr_mode == AM_MEMIO)
+               if (hw->ci->addr_mode == AM_MEMIO) {
                        hw->addr.p = ioremap(hw->addr.start, hw->addr.size);
+                       if (unlikely(!hw->addr.p))
+                               return -ENOMEM;
+               }
                hw->addr.mode = hw->ci->addr_mode;
                if (debug & DEBUG_HW)
                        pr_notice("%s: IO addr %lx (%lu bytes) mode%d\n",