From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 59715A00C5 for ; Fri, 29 May 2020 09:24:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1013D1DC34; Fri, 29 May 2020 09:24:56 +0200 (CEST) Received: from huawei.com (szxga08-in.huawei.com [45.249.212.255]) by dpdk.org (Postfix) with ESMTP id 04A491DC0A; Fri, 29 May 2020 09:24:51 +0200 (CEST) Received: from DGGEMM401-HUB.china.huawei.com (unknown [172.30.72.55]) by Forcepoint Email with ESMTP id A8C4981FFFFE1BE90AC0; Fri, 29 May 2020 15:24:50 +0800 (CST) Received: from DGGEMM533-MBX.china.huawei.com ([169.254.5.226]) by DGGEMM401-HUB.china.huawei.com ([10.3.20.209]) with mapi id 14.03.0487.000; Fri, 29 May 2020 15:24:40 +0800 From: wangyunjian To: Stephen Hemminger CC: "dev@dpdk.org" , "sthemmin@microsoft.com" , "Lilijun (Jerry)" , xudingke , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] bus/vmbus: fix wrong allocation for device.name Thread-Index: AQHWNOf+nvfj03Fhn0u+a/jtvEN/Gai9Ja+AgAFX1BA= Date: Fri, 29 May 2020 07:24:39 +0000 Message-ID: <34EFBCA9F01B0748BEB6B629CE643AE60D0195C9@DGGEMM533-MBX.china.huawei.com> References: <768c74d06680b93b2ce6bbf0813d1910666888dc.1590666521.git.wangyunjian@huawei.com> <20200528091237.7b87133f@hermes.lan> In-Reply-To: <20200528091237.7b87133f@hermes.lan> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.173.251.152] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] bus/vmbus: fix wrong allocation for device.name X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Friday, May 29, 2020 12:13 AM > To: wangyunjian > Cc: dev@dpdk.org; sthemmin@microsoft.com; Lilijun (Jerry) > ; xudingke ; > stable@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] bus/vmbus: fix wrong allocation for > device.name >=20 > On Thu, 28 May 2020 20:03:07 +0800 > wangyunjian wrote: >=20 > > From: Yunjian Wang > > > > 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 > > --- > > 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 =3D &rte_vmbus_bus.bus; > > - dev->device.name =3D 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 =3D vmbus_devargs_lookup(dev); > > + dev->device.name =3D dev->device.devargs->name; > > > > /* device is valid, add in list (sorted) */ > > VMBUS_LOG(DEBUG, "Adding vmbus device %s", name); >=20 > 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 direct= ly. Thanks, Yunjian