netconsole: enable netconsole can make net_device refcnt incorrent
authorGao feng <gaofeng@cn.fujitsu.com>
Tue, 11 Oct 2011 16:08:11 +0000 (16:08 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Oct 2011 03:55:29 +0000 (23:55 -0400)
There is no check if netconsole is enabled current.
so when exec echo 1 > enabled;
the reference of net_device will increment always.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
Acked-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/netconsole.c

index ed2a397..e888202 100644 (file)
@@ -307,6 +307,11 @@ static ssize_t store_enabled(struct netconsole_target *nt,
                return err;
        if (enabled < 0 || enabled > 1)
                return -EINVAL;
+       if (enabled == nt->enabled) {
+               printk(KERN_INFO "netconsole: network logging has already %s\n",
+                               nt->enabled ? "started" : "stopped");
+               return -EINVAL;
+       }
 
        if (enabled) {  /* 1 */