net: ehea: avoid null pointer dereference
authorxypron.glpk@gmx.de <xypron.glpk@gmx.de>
Tue, 17 May 2016 20:28:54 +0000 (22:28 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 19 May 2016 18:25:30 +0000 (11:25 -0700)
ehea_get_port may return NULL. Do not dereference NULL value.

Fixes: 8c4877a4128e ("ehea: Use the standard logging functions")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@debian.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ibm/ehea/ehea_main.c

index 2a0dc127df3f4e099e273a77715ad87358385aff..54efa9a5167b86021802b98900e6ff216fa10a73 100644 (file)
@@ -1169,16 +1169,15 @@ static void ehea_parse_eqe(struct ehea_adapter *adapter, u64 eqe)
        ec = EHEA_BMASK_GET(NEQE_EVENT_CODE, eqe);
        portnum = EHEA_BMASK_GET(NEQE_PORTNUM, eqe);
        port = ehea_get_port(adapter, portnum);
+       if (!port) {
+               netdev_err(NULL, "unknown portnum %x\n", portnum);
+               return;
+       }
        dev = port->netdev;
 
        switch (ec) {
        case EHEA_EC_PORTSTATE_CHG:     /* port state change */
 
-               if (!port) {
-                       netdev_err(dev, "unknown portnum %x\n", portnum);
-                       break;
-               }
-
                if (EHEA_BMASK_GET(NEQE_PORT_UP, eqe)) {
                        if (!netif_carrier_ok(dev)) {
                                ret = ehea_sense_port_attr(port);