LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* hostap_cs_{resume,suspend}(): inconsequent NULL checking
@ 2007-02-06 22:13 Adrian Bunk
  0 siblings, 0 replies; 2+ messages in thread
From: Adrian Bunk @ 2007-02-06 22:13 UTC (permalink / raw)
  To: jkmaline, linville; +Cc: hostap, netdev, linux-pcmcia, linux-kernel

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  -->

The problem is that if the "if (dev)" is false, there's a guaranteed 
NULL dereference later in the "prism2_suspend(dev)" resp.
"prism2_hw_config(dev, dev_open ? 0 : 1)".

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed



^ permalink raw reply	[flat|nested] 2+ messages in thread

* hostap_cs_{resume,suspend}(): inconsequent NULL checking
@ 2006-11-10 10:22 Adrian Bunk
  0 siblings, 0 replies; 2+ messages in thread
From: Adrian Bunk @ 2006-11-10 10:22 UTC (permalink / raw)
  To: linville; +Cc: netdev, linux-pcmcia, linux-kernel

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  -->

The problem is that if the "if (dev)" is false, there's a guaranteed 
NULL dereference later in the "prism2_suspend(dev)" resp.
"prism2_hw_config(dev, dev_open ? 0 : 1)".

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-02-06 22:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-06 22:13 hostap_cs_{resume,suspend}(): inconsequent NULL checking Adrian Bunk
  -- strict thread matches above, loose matches on Subject: below --
2006-11-10 10:22 Adrian Bunk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).