xen-netback: use kstrdup() in connect_data_rings()
Subsystems (2)
PATCH 1/1 xen-netback: use kstrdup() in connect_data_rings()
Use kstrdup() instead of opencoded alloc and copy. kzalloc() is excessive here.
Signed-off-by Denis Efremov <[email protected]>
--- drivers/net/xen-netback/xenbus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/xen-netback/xenbus.c +1 -2
@@ -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 );
Signature · 1 line
2.26.2
Quoted 4 lines · Denis Efremov
Use
kstrdup()instead of opencoded alloc and copy.kzalloc()is excessive here.Signed-off-by Denis Efremov <[email protected]>
Acked-by Wei Liu <[email protected]>
Quoted 26 lines
--- drivers/net/xen-netback/xenbus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/xen-netback/xenbus.c +1
-2@@ -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 );Signature · 1 line
2.26.2