Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp604845ybg; Wed, 3 Jun 2020 08:55:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOt7k+AUe96/gtIq+T13uj6EF7U47BKUzBfKXouZGt/VaaTXMHwkbY0ti6lhU7S9zSqF6j X-Received: by 2002:a17:906:11d9:: with SMTP id o25mr12660040eja.377.1591199743477; Wed, 03 Jun 2020 08:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591199743; cv=none; d=google.com; s=arc-20160816; b=dEFFNse5MHbT7/fR515fInhQ/KhnOri2TPIAkmnXTyJfGTLp7kZ6AF7JPFvTjQaskO 94XzJ5hXEnUa3u6+HF8kvy5qNeOlvl6PWpXtk8dBezImq1nKFRvwRfAMlUKlNp5huqwe tcKnwnE5NJQU/k2Kma0rCebv1tanp8WHdfq6L8tiL176YvMAqWN20nb6m1fAyN2i09Xv Y62foiXX2MCVNeqwJfErjk/tIxt0frXsI0QbGC0VOsQH8eYqwOLb5fXZIc22mkhFlMoc 9Po9wP08FQzGW1hooZM2S7hVmgDKKyu2ma9e3gdSQDUrBfMdstw6Fvb5w2WzTiTCeNUs 77+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=GshwwJK66k7h/1UU+52GCjHZuAKqpljzNfx76xeZPt4=; b=RFPR889aW7xdnvsHNu66bw6s1DEydkCQ4gnDFG2werB6HWfyPCLwMgozAFnDLzbfos Vk/UpqyxISGLozv/YNOs/+suzSshric5aW9kkcRwnBWV3agUfos2uMBk1oSEkIOcQDeJ L9BJ3dIX3R8lhdrr1oWlRXXB/h/mDYbtr6rfXywTpFW56FKPi25QUOHPcn4cXNiHwT9B IlkXcAyY9sI3P6sisJTb7DLbE2gNRFLT4ss2g9XaK7tNk76/5nRfqI6Dz7mT0YiELiL6 ageeQnTJNN7hMLZ0JmQZ9mJ0H1Sb9j8OgIuhTVm1S90L+vyzaFba1LXAPENWQParTQvp X1Dg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o22si1343461ejh.73.2020.06.03.08.55.18; Wed, 03 Jun 2020 08:55:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726154AbgFCPwo (ORCPT + 99 others); Wed, 3 Jun 2020 11:52:44 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:50774 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbgFCPwn (ORCPT ); Wed, 3 Jun 2020 11:52:43 -0400 Received: by mail-wm1-f66.google.com with SMTP id v19so2434406wmj.0 for ; Wed, 03 Jun 2020 08:52:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GshwwJK66k7h/1UU+52GCjHZuAKqpljzNfx76xeZPt4=; b=nl8dhKS4SaVRa9vcLq60bqwiJW9eB+axX36Jal7vfYHKsBeD/1+HLbKF45OzCUUvHl kLkpkg8ZGydHkFcSiHSIjUzQD2w2Upk4IDAudN4G3Ljozz56tRxVVAgrtatQCGqfIo93 r+8+7+LRr23KjG5j1MraDoVAyinYcz3J0T9QXmSFoGP20wn7mTyIfIYqYJo0BHJDbiS2 V9NBJai5my2gc1Yv8oULXfHcZNqq4/pAzTjAw7E9r7rBiEpqoiVE8mhzCFF8I2Ue8Hel j3K2maFbL4xjOMX+kMZ4a3KYlPZ90hfvQUhV8ZVsql4qhsaP6TrgooHUu03/c/gSca+q OowQ== X-Gm-Message-State: AOAM533/k/leKWgv6t5uK8H0MFq2LRYPL61wS3oBz/oyG8awGzmK4ztj AZbfhAU08Lb1sL8O7GQOpV0= X-Received: by 2002:a7b:cd10:: with SMTP id f16mr9537000wmj.149.1591199531131; Wed, 03 Jun 2020 08:52:11 -0700 (PDT) Received: from liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id q4sm3439264wma.47.2020.06.03.08.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2020 08:52:10 -0700 (PDT) Date: Wed, 3 Jun 2020 15:52:08 +0000 From: Wei Liu To: Denis Efremov Cc: "David S. Miller" , Paul Durrant , Wei Liu , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] xen-netback: use kstrdup() in connect_data_rings() Message-ID: <20200603155208.qmko4nd5on76k7c4@liuwe-devbox-debian-v2.j3c5onc20sse1dnehy4noqpfcg.zx.internal.cloudapp.net> References: <20200603152643.18215-1-efremov@linux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200603152643.18215-1-efremov@linux.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Wei Liu > --- > 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 >