Bug 9701 - hostap_cs_{resume,suspend}(): inconsequent NULL checking
Summary: hostap_cs_{resume,suspend}(): inconsequent NULL checking
Status: CLOSED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: network-wireless (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_network-wireless@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-05 19:42 UTC by Adrian Bunk
Modified: 2008-07-10 23:20 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.*
Subsystem:
Regression: ---
Bisected commit-id:


Attachments

Description Adrian Bunk 2008-01-05 19:42:06 UTC
The Coverity checker spotted the following in drivers/net/wireless/hostap/hostap_cs.c:

<--  snip  -->

...
static int hostap_cs_suspend(struct pcmcia_device *link)
{
        struct net_device *dev = (struct net_device *) link->priv;
        int dev_open = 0;
        struct hostap_interface *iface = NULL;

        if (dev)
                iface = netdev_priv(dev);

        PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
        if (iface && iface->local)
                dev_open = iface->local->num_dev_open > 0;
        if (dev_open) {
                netif_stop_queue(dev);
                netif_device_detach(dev);
        }
        prism2_suspend(dev);

        return 0;
}

static int hostap_cs_resume(struct pcmcia_device *link)
{
        struct net_device *dev = (struct net_device *) link->priv;
        int dev_open = 0;
        struct hostap_interface *iface = NULL;

        if (dev)
                iface = netdev_priv(dev);

        PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);

        if (iface && iface->local)
                dev_open = iface->local->num_dev_open > 0;

        prism2_hw_shutdown(dev, 1);
        prism2_hw_config(dev, dev_open ? 0 : 1);
        if (dev_open) {
                netif_device_attach(dev);
                netif_start_queue(dev);
        }

        return 0;
}
...

<--  snip  -->

If the "if (dev)" is false then there's a guaranteed NULL dereference later in the "prism2_suspend(dev)" resp. "prism2_hw_config(dev, dev_open ? 0 : 1)".
Comment 1 Natalie Protasevich 2008-06-05 00:09:00 UTC
Ugh, yes indeed! John, was this fixed somewhere? still same in the mainline...
Comment 2 Adrian Bunk 2008-07-10 23:20:18 UTC
fixed by commit fcee7a01ad7516eeb8dfdd0a17ef04cd2ee30757

Note You need to log in before you can comment on or make changes to this bug.