DPDK patches and discussions
 help / color / mirror / Atom feed
From: wangyunjian <wangyunjian@huawei.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"sthemmin@microsoft.com" <sthemmin@microsoft.com>,
	"Lilijun (Jerry)" <jerry.lilijun@huawei.com>,
	xudingke <xudingke@huawei.com>,
	"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] bus/vmbus: fix wrong allocation for device.name
Date: Fri, 29 May 2020 07:24:39 +0000	[thread overview]
Message-ID: <34EFBCA9F01B0748BEB6B629CE643AE60D0195C9@DGGEMM533-MBX.china.huawei.com> (raw)
In-Reply-To: <20200528091237.7b87133f@hermes.lan>



> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Friday, May 29, 2020 12:13 AM
> To: wangyunjian <wangyunjian@huawei.com>
> Cc: dev@dpdk.org; sthemmin@microsoft.com; Lilijun (Jerry)
> <jerry.lilijun@huawei.com>; xudingke <xudingke@huawei.com>;
> stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] bus/vmbus: fix wrong allocation for
> device.name
> 
> On Thu, 28 May 2020 20:03:07 +0800
> wangyunjian <wangyunjian@huawei.com> wrote:
> 
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > We do not need and should not allocate memory for device.name.
> > The device.name should be set point to the devargs->name.
> >
> > Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > ---
> >  drivers/bus/vmbus/linux/vmbus_bus.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/bus/vmbus/linux/vmbus_bus.c
> b/drivers/bus/vmbus/linux/vmbus_bus.c
> > index 3c924ee..31d0dd3 100644
> > --- a/drivers/bus/vmbus/linux/vmbus_bus.c
> > +++ b/drivers/bus/vmbus/linux/vmbus_bus.c
> > @@ -242,9 +242,6 @@
> >  		return -1;
> >
> >  	dev->device.bus = &rte_vmbus_bus.bus;
> > -	dev->device.name = strdup(name);
> > -	if (!dev->device.name)
> > -		goto error;
> >
> >  	/* sysfs base directory
> >  	 *   /sys/bus/vmbus/devices/7a08391f-f5a0-4ac0-9802-d13fd964f8df
> > @@ -296,6 +293,7 @@
> >  	}
> >
> >  	dev->device.devargs = vmbus_devargs_lookup(dev);
> > +	dev->device.name = dev->device.devargs->name;
> >
> >  	/* device is valid, add in list (sorted) */
> >  	VMBUS_LOG(DEBUG, "Adding vmbus device %s", name);
> 
> This doesn't seem right. devargs is not filled in unless devargs is used.

At present, the memory allocated for the device.name is not released
in the error handling code. I have not found the relevant code to release
the vmbus device, so I am not sure how to release it corrently.

Generally, the pointer of device.name should be set to another pointer.
However, it was defined as "const" pointer and could not be released directly.

Thanks,
Yunjian

  reply	other threads:[~2020-05-29  7:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 12:03 wangyunjian
2020-05-28 16:12 ` Stephen Hemminger
2020-05-29  7:24   ` wangyunjian [this message]
2020-05-29 17:47 ` Stephen Hemminger
2020-06-01  2:02   ` wangyunjian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34EFBCA9F01B0748BEB6B629CE643AE60D0195C9@DGGEMM533-MBX.china.huawei.com \
    --to=wangyunjian@huawei.com \
    --cc=dev@dpdk.org \
    --cc=jerry.lilijun@huawei.com \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=sthemmin@microsoft.com \
    --cc=xudingke@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).