Skip to contentSkip to conversation

netconsole: enable netconsole can make net_device refcnt incorrent

PATCH Superseded Gao feng 3 participants 5 messages Oct 11, 2011 – Oct 12, 2011

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Gao feng

author
#0 lore raw

PATCH 1/1 netconsole: enable netconsole can make net_device refcnt incorrent

There is no check if netconsole is enabled current.
so when exec echo 1 > enabled;
the reference of net_device will increment always.

---
 drivers/net/netconsole.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/netconsole.c +2 -0
index ed2a397..4e6323d 100644
@@ -307,6 +307,8 @@ static ssize_t store_enabled(struct netconsole_target *nt,
                return err;
        if (enabled < 0 || enabled > 1)
                return -EINVAL;
+       if (enabled == nt->enabled)
+               return err;
 
        if (enabled) {  /* 1 */
 
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 netconsole: enable netconsole can make net_device refcnt

There is no check if netconsole is enabled current. so when exec echo 1 > enabled;
the reference of net_device will increment always.

---
 drivers/net/netconsole.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/netconsole.c +2 -0
index ed2a397..4e6323df 100644
@@ -307,6 +307,8 @@ static ssize_t store_enabled(struct netconsole_target *nt,
 		return err;
 	if (enabled < 0 || enabled > 1)
 		return -EINVAL;
+	if (enabled == nt->enabled)
+		return err;
 
 	if (enabled) {	/* 1 */
 
Signature · 1 line
1.7.7.rc1
author
#2 lore raw

Re: [PATCH] netconsole: enable netconsole can make net_device refcnt

Im so sorry.
the first patch has some format err.
Please use this one.
thanks wanlong! ^V^

Quoted 22 lines · Wanlong Gao

There is no check if netconsole is enabled current. so when exec echo 1 > enabled;
the reference of net_device will increment always.

---
 drivers/net/netconsole.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/net/netconsole.c +2 -0
index ed2a397..4e6323df 100644
@@ -307,6 +307,8 @@ static ssize_t store_enabled(struct netconsole_target *nt,
 		return err;
 	if (enabled < 0 || enabled > 1)
 		return -EINVAL;
+	if (enabled == nt->enabled)
+		return err;
 
 	if (enabled) {	/* 1 */
 
#3 lore raw

Re: [PATCH] netconsole: enable netconsole can make net_device refcnt

Quoted 15 lines · On Tue, 11 Oct 2011 16:05:48 +0800 Gao feng <[email protected]> wrote:

Im so sorry.
the first patch has some format err.
Please use this one.
thanks wanlong! ^V^

Quoted 9 lines · Wanlong Gao

There is no check if netconsole is enabled current. so when exec echo 1 > enabled;
the reference of net_device will increment always.

---
 drivers/net/netconsole.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 10 lines

drivers/net/netconsole.c static ssize_t store_enabled(struct · line 311

Quoted 10 lines
drivers/net/netconsole.c +2 -0
index ed2a397..4e6323df 100644
@@ -307,6 +307,8 @@ static ssize_t store_enabled(struct
 netconsole_target *nt, return err;
 	if (enabled < 0 || enabled > 1)
 		return -EINVAL;
+	if (enabled == nt->enabled)
+		return err;

It looks like 'err' will be 0. Maybe it is better to return -EINVAL?

fbl

author
#4 lore raw

Re: [PATCH] netconsole: enable netconsole can make net_device refcnt

Quoted 32 lines · Flavio Leitner
Quoted 15 lines · On Tue, 11 Oct 2011 16:05:48 +0800 Gao feng <[email protected]> wrote:

Im so sorry.
the first patch has some format err.
Please use this one.
thanks wanlong! ^V^

Quoted 9 lines · Wanlong Gao

There is no check if netconsole is enabled current. so when exec echo 1 > enabled;
the reference of net_device will increment always.

---
 drivers/net/netconsole.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 10 lines

drivers/net/netconsole.c static ssize_t store_enabled(struct · line 311

Quoted 10 lines
drivers/net/netconsole.c +2 -0
index ed2a397..4e6323df 100644
@@ -307,6 +307,8 @@ static ssize_t store_enabled(struct
 netconsole_target *nt, return err;
 	if (enabled < 0 || enabled > 1)
 		return -EINVAL;
+	if (enabled == nt->enabled)
+		return err;

It looks like 'err' will be 0. Maybe it is better to return -EINVAL?

Quoted 2 lines

fbl

Yes,you are right,and I will add some printk.thanks.