xen-netback: corretly check failed allocation
Subsystems (3)
PATCH 1/1 xen-netback: corretly check failed allocation
Since vzalloc can be failed in memory pressure,
return value should be checked and return ENOMEM.
--- drivers/net/xen-netback/xenbus.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/xen-netback/xenbus.c +5 -0
@@ -788,6 +788,11 @@ static void connect(struct backend_info *be)/* Use the number of queues requested by the frontend */ be->vif->queues =vzalloc (requested_num_queues *sizeof (struct xenvif_queue )); +if (!be->vif->queues) { +xenbus_dev_fatal (dev, -ENOMEM ,"allocating queues" ); +return ; + } + be->vif->num_queues = requested_num_queues; be->vif->stalled_queues = requested_num_queues;
Signature · 1 line
1.9.1
Quoted 14 lines · Insu Yun
Since vzalloc can be failed in memory pressure,
return value should be checked and return ENOMEM.Signed-off-by Insu Yun <[email protected]>--- drivers/net/xen-netback/xenbus.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/xen renamed from drivers/net/xen-netback/xenbus.c +0
-1-netback/xenbus.cindex 929a6e7..e288246 100644
drivers/net/xen-netback/xenbus.c static void connect(struct backend_info *be) · line 794
Quoted 7 lines
drivers/net/xen-netback/xenbus.c +4
-0@@ -788,6 +788,11 @@ static void connect(struct backend_info *be)/* Use the number of queues requested by the frontend */ be->vif->queues =vzalloc (requested_num_queues *sizeof (struct xenvif_queue )); +if (!be->vif->queues) { +xenbus_dev_fatal (dev, -ENOMEM ,"allocating queues" ); +return ; + }
Please fix the coding style, perhaps using checkpatch.pl or by observing the surrounding code.
Ian.
Quoted 4 lines
drivers/net/xen-netback/xenbus.c +1
-0+ be->vif->num_queues = requested_num_queues; be->vif->stalled_queues = requested_num_queues;
Quoted 14 lines · Insu Yun
Since vzalloc can be failed in memory pressure,
return value should be checked and return ENOMEM.Signed-off-by Insu Yun <[email protected]>--- drivers/net/xen-netback/xenbus.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/xen renamed from drivers/net/xen-netback/xenbus.c +0
-1-netback/xenbus.cindex 929a6e7..e288246 100644
drivers/net/xen-netback/xenbus.c static void connect(struct backend_info *be) · line 794
Quoted 7 lines
drivers/net/xen-netback/xenbus.c +4
-0@@ -788,6 +788,11 @@ static void connect(struct backend_info *be)/* Use the number of queues requested by the frontend */ be->vif->queues =vzalloc (requested_num_queues *sizeof (struct xenvif_queue )); +if (!be->vif->queues) { +xenbus_dev_fatal (dev, -ENOMEM ,"allocating queues" ); +return ; + }
Please fix the coding style, perhaps using checkpatch.pl or by observing the surrounding code.
Ian.
Quoted 4 lines
drivers/net/xen-netback/xenbus.c +1
-0+ be->vif->num_queues = requested_num_queues; be->vif->stalled_queues = requested_num_queues;
Quoted 2 lines · Insu Yun
Since vzalloc can be failed in memory pressure,
return value should be checked and return ENOMEM.
This function doesn't return ENOMEM, instead it writes to xenstore to indicate error. The commit log needs to be updated.
Quoted 11 lines
Signed-off-by Insu Yun <[email protected]>--- drivers/net/xen-netback/xenbus.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/xen-netback/xenbus.c +0
-0
drivers/net/xen-netback/xenbus.c static void connect(struct backend_info *be) · line 795
Quoted 8 lines
drivers/net/xen-netback/xenbus.c +5
-0@@ -788,6 +788,11 @@ static void connect(struct backend_info *be)/* Use the number of queues requested by the frontend */ be->vif->queues =vzalloc (requested_num_queues *sizeof (struct xenvif_queue )); +if (!be->vif->queues) { +xenbus_dev_fatal (dev, -ENOMEM ,"allocating queues" ); +return ; + } +
The indentation is wrong. Please configure your email client properly.
And please use "goto err" for error handling -- yes, I understand there is existing code that returns directly but IMHO that should be fixed too.
We.
Quoted 5 lines
drivers/net/xen-netback/xenbus.c +0
-0be->vif->num_queues = requested_num_queues; be->vif->stalled_queues = requested_num_queues;Signature · 1 line
1.9.1
Sorry for wrong format, I forgot to change my configuration.
Quoted 8 lines · Wei Liu
Quoted 2 lines · Insu Yun
Since vzalloc can be failed in memory pressure,
return value should be checked and return ENOMEM.This function doesn't return ENOMEM, instead it writes to xenstore to indicate error. The commit log needs to be updated.
Good. I will update it.
Quoted 23 lines
Review
Quoted 7 lines
Signed-off-by Insu Yun <[email protected]>--- drivers/net/xen-netback/xenbus.c | 5 +++++ 1 file changed, 5 insertions(+)(quoted diff) +0
-0
b/drivers/net/xen-netback/xenbus.cdrivers/net/xen-netback/xenbus.c static void connect(struct backend_info *be) · line 795
Quoted 12 lines
index 929a6e7..e288246 100644
drivers/net/xen-netback/xenbus.c +5
-0@@ -788,6 +788,11 @@ static void connect(struct backend_info *be)/* Use the number of queues requested by the frontend */ be->vif->queues =vzalloc (requested_num_queues *sizeof (struct xenvif_queue )); +if (!be->vif->queues) { +xenbus_dev_fatal (dev, -ENOMEM ,"allocating queues" ); +return ; + } +The indentation is wrong. Please configure your email client properly.
Quoted 5 lines
And please use "goto err" for error handling -- yes, I understand there is existing code that returns directly but IMHO that should be fixed too.
Ok. Actually I made a code referring the existing code.
Quoted 8 lines
We.
Quoted 5 lines
drivers/net/xen-netback/xenbus.c +0
-1be->vif->num_queues = requested_num_queues; be->vif->stalled_queues = requested_num_queues; --1.9.1
Signature · 2 lines
Regards Insu Yun
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 2 lines · Insu Yun
Since vzalloc can be failed in memory pressure,
return value should be checked and return ENOMEM.
This function doesn't return ENOMEM, instead it writes to xenstore to indicate error. The commit log needs to be updated.
Quoted 11 lines
Signed-off-by Insu Yun <[email protected]>--- drivers/net/xen-netback/xenbus.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/xen-netback/xenbus.c +0
-0
drivers/net/xen-netback/xenbus.c static void connect(struct backend_info *be) · line 795
Quoted 8 lines
drivers/net/xen-netback/xenbus.c +5
-0@@ -788,6 +788,11 @@ static void connect(struct backend_info *be)/* Use the number of queues requested by the frontend */ be->vif->queues =vzalloc (requested_num_queues *sizeof (struct xenvif_queue )); +if (!be->vif->queues) { +xenbus_dev_fatal (dev, -ENOMEM ,"allocating queues" ); +return ; + } +
The indentation is wrong. Please configure your email client properly.
And please use "goto err" for error handling -- yes, I understand there is existing code that returns directly but IMHO that should be fixed too.
We.
Quoted 5 lines
drivers/net/xen-netback/xenbus.c +0
-0be->vif->num_queues = requested_num_queues; be->vif->stalled_queues = requested_num_queues;Signature · 1 line
1.9.1
David Miller
maintainerFrom: Insu Yun <[email protected]>
Date: Thu, 15 Oct 2015 12:26:16 -0400
Quoted 13 lines
Since vzalloc can be failed in memory pressure,
return value should be checked and return ENOMEM.Signed-off-by Insu Yun <[email protected]>--- drivers/net/xen-netback/xenbus.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/xen-netback/xenbus.c +0
-0
drivers/net/xen-netback/xenbus.c static void connect(struct backend_info *be) · line 794
Quoted 7 lines
drivers/net/xen-netback/xenbus.c +4
-0@@ -788,6 +788,11 @@ static void connect(struct backend_info *be)/* Use the number of queues requested by the frontend */ be->vif->queues =vzalloc (requested_num_queues *sizeof (struct xenvif_queue )); +if (!be->vif->queues) { +xenbus_dev_fatal (dev, -ENOMEM ,"allocating queues" ); +return ; + }
This is definitely not indented correctly.
David Miller
maintainerFrom: Insu Yun <[email protected]>
Date: Thu, 15 Oct 2015 12:26:16 -0400
Quoted 13 lines
Since vzalloc can be failed in memory pressure,
return value should be checked and return ENOMEM.Signed-off-by Insu Yun <[email protected]>--- drivers/net/xen-netback/xenbus.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/xen-netback/xenbus.c +0
-0
drivers/net/xen-netback/xenbus.c static void connect(struct backend_info *be) · line 794
Quoted 7 lines
drivers/net/xen-netback/xenbus.c +4
-0@@ -788,6 +788,11 @@ static void connect(struct backend_info *be)/* Use the number of queues requested by the frontend */ be->vif->queues =vzalloc (requested_num_queues *sizeof (struct xenvif_queue )); +if (!be->vif->queues) { +xenbus_dev_fatal (dev, -ENOMEM ,"allocating queues" ); +return ; + }
This is definitely not indented correctly.