[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200603152643.18215-1-efremov@linux.com>
Date: Wed, 3 Jun 2020 18:26:43 +0300
From: Denis Efremov <efremov@...ux.com>
To: "David S. Miller" <davem@...emloft.net>
Cc: Denis Efremov <efremov@...ux.com>, Paul Durrant <paul@....org>,
Wei Liu <wei.liu@...nel.org>, xen-devel@...ts.xenproject.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] 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 <efremov@...ux.com>
---
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
Powered by blists - more mailing lists