[PATCH 1/3] net: fail alloc_netdev_mq if queue count < 1

Subsystems: networking [general], the rest

STALE5793d

3 messages, 2 authors, 2010-10-18 · open the first message on its own page

[PATCH 1/3] net: fail alloc_netdev_mq if queue count < 1

From: Tom Herbert <hidden>
Date: 2010-10-18 18:02:14

In alloc_netdev_mq fail if requested queue_count < 1.

Signed-off-by: Tom Herbert <redacted>
---
 net/core/dev.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 04972a4..76db105 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5511,6 +5511,12 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
 
 	BUG_ON(strlen(name) >= sizeof(dev->name));
 
+	if (queue_count < 0) {
+		printk(KERN_ERR "alloc_netdev: Unable to allocate device "
+		       "with zero queues.\n");
+		return NULL;
+	}
+
 	alloc_size = sizeof(struct net_device);
 	if (sizeof_priv) {
 		/* ensure 32-byte alignment of private area */
-- 
1.7.1

Re: [PATCH 1/3] net: fail alloc_netdev_mq if queue count < 1

From: Ben Hutchings <hidden>
Date: 2010-10-18 21:33:45

On Mon, 2010-10-18 at 11:02 -0700, Tom Herbert wrote:
quoted hunk
In alloc_netdev_mq fail if requested queue_count < 1.

Signed-off-by: Tom Herbert <redacted>
---
 net/core/dev.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 04972a4..76db105 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5511,6 +5511,12 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
 
 	BUG_ON(strlen(name) >= sizeof(dev->name));
 
+	if (queue_count < 0) {
+		printk(KERN_ERR "alloc_netdev: Unable to allocate device "
+		       "with zero queues.\n");
Off by one?

Ben.
+		return NULL;
+	}
+
 	alloc_size = sizeof(struct net_device);
 	if (sizeof_priv) {
 		/* ensure 32-byte alignment of private area */
-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

Re: [PATCH 1/3] net: fail alloc_netdev_mq if queue count < 1

From: Tom Herbert <hidden>
Date: 2010-10-18 21:46:15

Off by one?
Yes, thanks for catching that.
Ben.
quoted
+             return NULL;
+     }
+
      alloc_size = sizeof(struct net_device);
      if (sizeof_priv) {
              /* ensure 32-byte alignment of private area */
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help