* [PATCH] xen-netback: use kstrdup() in connect_data_rings()
@ 2020-06-03 15:26 Denis Efremov
2020-06-03 15:52 ` Wei Liu
0 siblings, 1 reply; 2+ messages in thread
From: Denis Efremov @ 2020-06-03 15:26 UTC (permalink / raw)
To: David S. Miller
Cc: Denis Efremov, Paul Durrant, Wei Liu, xen-devel, linux-kernel
Use kstrdup() instead of opencoded alloc and copy. kzalloc() is
excessive here.
Signed-off-by: Denis Efremov <efremov@linux.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xen-netback: use kstrdup() in connect_data_rings()
2020-06-03 15:26 [PATCH] xen-netback: use kstrdup() in connect_data_rings() Denis Efremov
@ 2020-06-03 15:52 ` Wei Liu
0 siblings, 0 replies; 2+ messages in thread
From: Wei Liu @ 2020-06-03 15:52 UTC (permalink / raw)
To: Denis Efremov
Cc: David S. Miller, Paul Durrant, Wei Liu, xen-devel, linux-kernel
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@linux.com>
Acked-by: Wei Liu <wei.liu@kernel.org>
> ---
> 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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-03 15:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 15:26 [PATCH] xen-netback: use kstrdup() in connect_data_rings() Denis Efremov
2020-06-03 15:52 ` Wei Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).