]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging/slicoss: Check pointer before dereferencing
authorPeter Huewe <peterhuewe@gmx.de>
Tue, 19 Feb 2013 04:13:50 +0000 (05:13 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 11 Mar 2013 16:22:43 +0000 (09:22 -0700)
Smatch complains that the variable adapter is dereferenced before it is
checked:
slicoss.c:906 slic_timer_load_check() warn: variable dereferenced before
check 'adapter' (see line 904)

-> move the assignment after the check.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/slicoss/slicoss.c

index 76fc2e554f3522453c2d1b9a3058a129d8e2f3a0..753993c867fa3aa950c55e7dc3ecaf16cc29c1c7 100644 (file)
@@ -901,10 +901,9 @@ static void slic_timer_load_check(ulong cardaddr)
        u32 load = card->events;
        u32 level = 0;
 
-       intagg = &adapter->slic_regs->slic_intagg;
-
        if ((adapter) && (adapter->state == ADAPT_UP) &&
            (card->state == CARD_UP) && (slic_global.dynamic_intagg)) {
+               intagg = &adapter->slic_regs->slic_intagg;
                if (adapter->devid == SLIC_1GB_DEVICE_ID) {
                        if (adapter->linkspeed == LINK_1000MB)
                                level = 100;