* [PATCH 1/1] xen-netfront: update num_queues to real created
@ 2015-10-15 2:34 Joe Jin
2015-10-16 10:56 ` Wei Liu
2015-10-16 10:56 ` Wei Liu
0 siblings, 2 replies; 6+ messages in thread
From: Joe Jin @ 2015-10-15 2:34 UTC (permalink / raw)
To: wei.liu2, Ian Campbell, David S. Miller, annie.li, Konrad Rzeszutek Wilk
Cc: netdev, xen-devel, stable
Sometimes xennet_create_queues() may failed to created all requested
queues, we need to update num_queues to real created to avoid NULL
pointer dereference.
Signed-off-by: Joe Jin <joe.jin@oracle.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: David S. Miller <davem@davemloft.net>
---
drivers/net/xen-netfront.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index f821a97..d580aec 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1746,7 +1746,7 @@ static int xennet_create_queues(struct netfront_info *info,
dev_err(&info->netdev->dev, "no queues\n");
return -EINVAL;
}
- return 0;
+ return num_queues;
}
/* Common code used when first setting up, and when resuming. */
@@ -1788,9 +1788,12 @@ static int talk_to_netback(struct xenbus_device *dev,
if (info->queues)
xennet_destroy_queues(info);
- err = xennet_create_queues(info, num_queues);
- if (err < 0)
+ /* Update queues number to real created */
+ num_queues = xennet_create_queues(info, num_queues);
+ if (num_queues < 0) {
+ err = num_queues;
goto destroy_ring;
+ }
/* Create shared ring, alloc event channel -- for each queue */
for (i = 0; i < num_queues; ++i) {
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] xen-netfront: update num_queues to real created
2015-10-15 2:34 [PATCH 1/1] xen-netfront: update num_queues to real created Joe Jin
2015-10-16 10:56 ` Wei Liu
@ 2015-10-16 10:56 ` Wei Liu
2015-10-16 12:15 ` Boris Ostrovsky
2015-10-16 12:15 ` Boris Ostrovsky
1 sibling, 2 replies; 6+ messages in thread
From: Wei Liu @ 2015-10-16 10:56 UTC (permalink / raw)
To: Joe Jin
Cc: wei.liu2, Ian Campbell, David S. Miller, annie.li,
Konrad Rzeszutek Wilk, netdev, xen-devel, stable, David Vrabel,
Boris Ostrovsky
CC David and Boris (Konrad was already a recipient).
On Thu, Oct 15, 2015 at 10:34:15AM +0800, Joe Jin wrote:
> Sometimes xennet_create_queues() may failed to created all requested
> queues, we need to update num_queues to real created to avoid NULL
> pointer dereference.
>
> Signed-off-by: Joe Jin <joe.jin@oracle.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> Cc: David S. Miller <davem@davemloft.net>
> ---
> drivers/net/xen-netfront.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
> index f821a97..d580aec 100644
> --- a/drivers/net/xen-netfront.c
> +++ b/drivers/net/xen-netfront.c
> @@ -1746,7 +1746,7 @@ static int xennet_create_queues(struct netfront_info *info,
> dev_err(&info->netdev->dev, "no queues\n");
> return -EINVAL;
> }
> - return 0;
> + return num_queues;
> }
>
> /* Common code used when first setting up, and when resuming. */
> @@ -1788,9 +1788,12 @@ static int talk_to_netback(struct xenbus_device *dev,
> if (info->queues)
> xennet_destroy_queues(info);
>
> - err = xennet_create_queues(info, num_queues);
> - if (err < 0)
> + /* Update queues number to real created */
> + num_queues = xennet_create_queues(info, num_queues);
> + if (num_queues < 0) {
> + err = num_queues;
> goto destroy_ring;
> + }
>
> /* Create shared ring, alloc event channel -- for each queue */
> for (i = 0; i < num_queues; ++i) {
> --
> 1.7.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] xen-netfront: update num_queues to real created
2015-10-15 2:34 [PATCH 1/1] xen-netfront: update num_queues to real created Joe Jin
@ 2015-10-16 10:56 ` Wei Liu
2015-10-16 10:56 ` Wei Liu
1 sibling, 0 replies; 6+ messages in thread
From: Wei Liu @ 2015-10-16 10:56 UTC (permalink / raw)
To: Joe Jin
Cc: wei.liu2, Ian Campbell, netdev, stable, annie.li, David Vrabel,
xen-devel, Boris Ostrovsky, David S. Miller
CC David and Boris (Konrad was already a recipient).
On Thu, Oct 15, 2015 at 10:34:15AM +0800, Joe Jin wrote:
> Sometimes xennet_create_queues() may failed to created all requested
> queues, we need to update num_queues to real created to avoid NULL
> pointer dereference.
>
> Signed-off-by: Joe Jin <joe.jin@oracle.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> Cc: David S. Miller <davem@davemloft.net>
> ---
> drivers/net/xen-netfront.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
> index f821a97..d580aec 100644
> --- a/drivers/net/xen-netfront.c
> +++ b/drivers/net/xen-netfront.c
> @@ -1746,7 +1746,7 @@ static int xennet_create_queues(struct netfront_info *info,
> dev_err(&info->netdev->dev, "no queues\n");
> return -EINVAL;
> }
> - return 0;
> + return num_queues;
> }
>
> /* Common code used when first setting up, and when resuming. */
> @@ -1788,9 +1788,12 @@ static int talk_to_netback(struct xenbus_device *dev,
> if (info->queues)
> xennet_destroy_queues(info);
>
> - err = xennet_create_queues(info, num_queues);
> - if (err < 0)
> + /* Update queues number to real created */
> + num_queues = xennet_create_queues(info, num_queues);
> + if (num_queues < 0) {
> + err = num_queues;
> goto destroy_ring;
> + }
>
> /* Create shared ring, alloc event channel -- for each queue */
> for (i = 0; i < num_queues; ++i) {
> --
> 1.7.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] xen-netfront: update num_queues to real created
2015-10-16 10:56 ` Wei Liu
2015-10-16 12:15 ` Boris Ostrovsky
@ 2015-10-16 12:15 ` Boris Ostrovsky
1 sibling, 0 replies; 6+ messages in thread
From: Boris Ostrovsky @ 2015-10-16 12:15 UTC (permalink / raw)
To: Wei Liu, Joe Jin
Cc: Ian Campbell, David S. Miller, annie.li, Konrad Rzeszutek Wilk,
netdev, xen-devel, stable, David Vrabel
On 10/16/2015 06:56 AM, Wei Liu wrote:
> CC David and Boris (Konrad was already a recipient).
>
> On Thu, Oct 15, 2015 at 10:34:15AM +0800, Joe Jin wrote:
>> Sometimes xennet_create_queues() may failed to created all requested
>> queues, we need to update num_queues to real created to avoid NULL
>> pointer dereference.
>>
>> Signed-off-by: Joe Jin <joe.jin@oracle.com>
>> Cc: Wei Liu <wei.liu2@citrix.com>
>> Cc: Ian Campbell <ian.campbell@citrix.com>
>> Cc: David S. Miller <davem@davemloft.net>
>> ---
>> drivers/net/xen-netfront.c | 9 ++++++---
>> 1 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
>> index f821a97..d580aec 100644
>> --- a/drivers/net/xen-netfront.c
>> +++ b/drivers/net/xen-netfront.c
>> @@ -1746,7 +1746,7 @@ static int xennet_create_queues(struct netfront_info *info,
>> dev_err(&info->netdev->dev, "no queues\n");
>> return -EINVAL;
>> }
>> - return 0;
>> + return num_queues;
>> }
>>
>> /* Common code used when first setting up, and when resuming. */
>> @@ -1788,9 +1788,12 @@ static int talk_to_netback(struct xenbus_device *dev,
>> if (info->queues)
>> xennet_destroy_queues(info);
>>
>> - err = xennet_create_queues(info, num_queues);
>> - if (err < 0)
>> + /* Update queues number to real created */
>> + num_queues = xennet_create_queues(info, num_queues);
I think it would be more natural to have
err = xennet_create_queues(info, &num_queues);
-boris
>> + if (num_queues < 0) {
>> + err = num_queues;
>> goto destroy_ring;
>> + }
>>
>> /* Create shared ring, alloc event channel -- for each queue */
>> for (i = 0; i < num_queues; ++i) {
>> --
>> 1.7.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] xen-netfront: update num_queues to real created
2015-10-16 10:56 ` Wei Liu
@ 2015-10-16 12:15 ` Boris Ostrovsky
2015-10-16 12:15 ` Boris Ostrovsky
1 sibling, 0 replies; 6+ messages in thread
From: Boris Ostrovsky @ 2015-10-16 12:15 UTC (permalink / raw)
To: Wei Liu, Joe Jin
Cc: Ian Campbell, netdev, stable, annie.li, David Vrabel, xen-devel,
David S. Miller
On 10/16/2015 06:56 AM, Wei Liu wrote:
> CC David and Boris (Konrad was already a recipient).
>
> On Thu, Oct 15, 2015 at 10:34:15AM +0800, Joe Jin wrote:
>> Sometimes xennet_create_queues() may failed to created all requested
>> queues, we need to update num_queues to real created to avoid NULL
>> pointer dereference.
>>
>> Signed-off-by: Joe Jin <joe.jin@oracle.com>
>> Cc: Wei Liu <wei.liu2@citrix.com>
>> Cc: Ian Campbell <ian.campbell@citrix.com>
>> Cc: David S. Miller <davem@davemloft.net>
>> ---
>> drivers/net/xen-netfront.c | 9 ++++++---
>> 1 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
>> index f821a97..d580aec 100644
>> --- a/drivers/net/xen-netfront.c
>> +++ b/drivers/net/xen-netfront.c
>> @@ -1746,7 +1746,7 @@ static int xennet_create_queues(struct netfront_info *info,
>> dev_err(&info->netdev->dev, "no queues\n");
>> return -EINVAL;
>> }
>> - return 0;
>> + return num_queues;
>> }
>>
>> /* Common code used when first setting up, and when resuming. */
>> @@ -1788,9 +1788,12 @@ static int talk_to_netback(struct xenbus_device *dev,
>> if (info->queues)
>> xennet_destroy_queues(info);
>>
>> - err = xennet_create_queues(info, num_queues);
>> - if (err < 0)
>> + /* Update queues number to real created */
>> + num_queues = xennet_create_queues(info, num_queues);
I think it would be more natural to have
err = xennet_create_queues(info, &num_queues);
-boris
>> + if (num_queues < 0) {
>> + err = num_queues;
>> goto destroy_ring;
>> + }
>>
>> /* Create shared ring, alloc event channel -- for each queue */
>> for (i = 0; i < num_queues; ++i) {
>> --
>> 1.7.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] xen-netfront: update num_queues to real created
@ 2015-10-15 2:34 Joe Jin
0 siblings, 0 replies; 6+ messages in thread
From: Joe Jin @ 2015-10-15 2:34 UTC (permalink / raw)
To: wei.liu2, Ian Campbell, David S. Miller, annie.li, Konrad Rzeszutek Wilk
Cc: netdev, stable, xen-devel
Sometimes xennet_create_queues() may failed to created all requested
queues, we need to update num_queues to real created to avoid NULL
pointer dereference.
Signed-off-by: Joe Jin <joe.jin@oracle.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: David S. Miller <davem@davemloft.net>
---
drivers/net/xen-netfront.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index f821a97..d580aec 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1746,7 +1746,7 @@ static int xennet_create_queues(struct netfront_info *info,
dev_err(&info->netdev->dev, "no queues\n");
return -EINVAL;
}
- return 0;
+ return num_queues;
}
/* Common code used when first setting up, and when resuming. */
@@ -1788,9 +1788,12 @@ static int talk_to_netback(struct xenbus_device *dev,
if (info->queues)
xennet_destroy_queues(info);
- err = xennet_create_queues(info, num_queues);
- if (err < 0)
+ /* Update queues number to real created */
+ num_queues = xennet_create_queues(info, num_queues);
+ if (num_queues < 0) {
+ err = num_queues;
goto destroy_ring;
+ }
/* Create shared ring, alloc event channel -- for each queue */
for (i = 0; i < num_queues; ++i) {
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-10-16 12:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-15 2:34 [PATCH 1/1] xen-netfront: update num_queues to real created Joe Jin
2015-10-16 10:56 ` Wei Liu
2015-10-16 10:56 ` Wei Liu
2015-10-16 12:15 ` Boris Ostrovsky
2015-10-16 12:15 ` Boris Ostrovsky
2015-10-15 2:34 Joe Jin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.