[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen-netback: use kstrdup() in connect_data_rings()



On Wed, Jun 03, 2020 at 06:26:43PM +0300, Denis Efremov wrote:
> Use kstrdup() instead of opencoded alloc and copy. kzalloc() is
> excessive here.
> 
> Signed-off-by: Denis Efremov <efremov@xxxxxxxxx>

Acked-by: Wei Liu <wei.liu@xxxxxxxxxx>

> ---
>  drivers/net/xen-netback/xenbus.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/xen-netback/xenbus.c 
> b/drivers/net/xen-netback/xenbus.c
> index 286054b60d47..69352154a51b 100644
> --- a/drivers/net/xen-netback/xenbus.c
> +++ b/drivers/net/xen-netback/xenbus.c
> @@ -839,13 +839,12 @@ static int connect_data_rings(struct backend_info *be,
>        * queue-N.
>        */
>       if (num_queues == 1) {
> -             xspath = kzalloc(strlen(dev->otherend) + 1, GFP_KERNEL);
> +             xspath = kstrdup(dev->otherend, GFP_KERNEL);
>               if (!xspath) {
>                       xenbus_dev_fatal(dev, -ENOMEM,
>                                        "reading ring references");
>                       return -ENOMEM;
>               }
> -             strcpy(xspath, dev->otherend);
>       } else {
>               xspathsize = strlen(dev->otherend) + xenstore_path_ext_size;
>               xspath = kzalloc(xspathsize, GFP_KERNEL);
> -- 
> 2.26.2
> 



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.