diff mbox

[13/13] net_sched: return NULL instead of ERR_PTR for qdisc_alloc()

Message ID 1415123796-8093-14-git-send-email-xiyou.wangcong@gmail.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Cong Wang Nov. 4, 2014, 5:56 p.m. UTC
It always returns ENOFBUFS so we can return NULL
and let its callers set this errno.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 net/sched/sch_api.c     | 4 ++--
 net/sched/sch_generic.c | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 38c42bd..27bfd75 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -905,8 +905,8 @@  qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
 		goto err_out;
 
 	sch = qdisc_alloc(dev_queue, ops);
-	if (IS_ERR(sch)) {
-		err = PTR_ERR(sch);
+	if (!sch) {
+		err = -ENOBUFS;
 		goto err_out2;
 	}
 
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 29db9c8..b474fbb 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -585,7 +585,6 @@  struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
 	void *p;
 	struct Qdisc *sch;
 	unsigned int size = QDISC_ALIGN(sizeof(*sch)) + ops->priv_size;
-	int err = -ENOBUFS;
 	struct net_device *dev = dev_queue->dev;
 
 	p = kzalloc_node(size, GFP_KERNEL,
@@ -620,7 +619,7 @@  struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
 
 	return sch;
 errout:
-	return ERR_PTR(err);
+	return NULL;
 }
 
 struct Qdisc *qdisc_create_internal(struct netdev_queue *dev_queue,
@@ -633,7 +632,7 @@  struct Qdisc *qdisc_create_internal(struct netdev_queue *dev_queue,
 		goto errout;
 
 	sch = qdisc_alloc(dev_queue, ops);
-	if (IS_ERR(sch))
+	if (!sch)
 		goto errout;
 	sch->parent = parentid;