qeth: Fix for possible null pointer dereference
authorRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Wed, 28 May 2014 08:22:30 +0000 (10:22 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 31 May 2014 00:35:23 +0000 (17:35 -0700)
There is otherwise a risk of a possible null pointer dereference.

Was largely found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: Frank Blaschka <blaschka@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/qeth_core_main.c

index 34993009a9e12d67df04ff06f10a46d5dd2cb58e..549e9fd5bfdcab566a06f8e5beeefc09114d9bd8 100644 (file)
@@ -1013,7 +1013,7 @@ static long __qeth_check_irb_error(struct ccw_device *cdev,
 
        card = CARD_FROM_CDEV(cdev);
 
-       if (!IS_ERR(irb))
+       if (!card || !IS_ERR(irb))
                return 0;
 
        switch (PTR_ERR(irb)) {
@@ -1029,7 +1029,7 @@ static long __qeth_check_irb_error(struct ccw_device *cdev,
                QETH_CARD_TEXT(card, 2, "ckirberr");
                QETH_CARD_TEXT_(card, 2, "  rc%d", -ETIMEDOUT);
                if (intparm == QETH_RCD_PARM) {
-                       if (card && (card->data.ccwdev == cdev)) {
+                       if (card->data.ccwdev == cdev) {
                                card->data.state = CH_STATE_DOWN;
                                wake_up(&card->wait_q);
                        }