Skip to content

Commit

Permalink
slip: remove dead code within the slip initialization
Browse files Browse the repository at this point in the history
This following code contains a dead "if (dev).." block:
        ...
        for (i = 0; i < slip_maxdev; i++) {
                dev = slip_devs[i];
                if (dev == NULL)
                        break;
        }
        /* Sorry, too many, all slots in use */
        if (i >= slip_maxdev)
                return NULL;

        if (dev) {
                sl = netdev_priv(dev);
                if (test_bit(SLF_INUSE, &sl->flags)) {
                        unregister_netdevice(dev);
                        dev = NULL;
                        slip_devs[i] = NULL;
                }
         }
        ...
The reason is that the code starting with "if (dev).." is never called as
when we found an empty slot (dev == NULL) we break the loop and "if (dev).."
not works eiter the loop ends and we get out with "i >= slip_maxdev".

Signed-off-by: Matvejchikov Ilya <matvejchikov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Matvejchikov Ilya authored and David S. Miller committed Jul 13, 2011
1 parent 9173a88 commit 390fd0b
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions drivers/net/slip.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ static void sl_sync(void)
static struct slip *sl_alloc(dev_t line)
{
int i;
char name[IFNAMSIZ];
struct net_device *dev = NULL;
struct slip *sl;

Expand All @@ -735,25 +736,12 @@ static struct slip *sl_alloc(dev_t line)
if (i >= slip_maxdev)
return NULL;

if (dev) {
sl = netdev_priv(dev);
if (test_bit(SLF_INUSE, &sl->flags)) {
unregister_netdevice(dev);
dev = NULL;
slip_devs[i] = NULL;
}
}

if (!dev) {
char name[IFNAMSIZ];
sprintf(name, "sl%d", i);

dev = alloc_netdev(sizeof(*sl), name, sl_setup);
if (!dev)
return NULL;
dev->base_addr = i;
}
sprintf(name, "sl%d", i);
dev = alloc_netdev(sizeof(*sl), name, sl_setup);
if (!dev)
return NULL;

dev->base_addr = i;
sl = netdev_priv(dev);

/* Initialize channel control data */
Expand Down

0 comments on commit 390fd0b

Please sign in to comment.