From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 44AE9A0032; Wed, 29 Sep 2021 22:57:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BE804410EB; Wed, 29 Sep 2021 22:57:18 +0200 (CEST) Received: from na01-obe.outbound.protection.outlook.com (mail-oln040093003011.outbound.protection.outlook.com [40.93.3.11]) by mails.dpdk.org (Postfix) with ESMTP id B5FB1410EA; Wed, 29 Sep 2021 22:57:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xy6YcmFRlfgw88udDepSyidYiHDDdbSbIJsXRyctTie2Twdbmq3AKFf0ctfJBNloSnEpk4Ycv0VOHna95n7GOowMwq+slxkPP1HTiN2iZfvYOHfLaAl/Al718zwqrocP+NuxIKnhB1PU+w3WdivZ6PFpXanhUF4+yFtKwu70lDaAsSib2N3shrPV8x+IErkdlOMN5eUzRuXumL87didQ22iqKD3gUyFmZVO4ncaSiOomo1sktOFElesmOKUIYHnVwCpF5u34F038aWzvA9Lxcq7OUHMMDIRfzQm2CLHcPhSLDrjTKYapAZzdPIfsIqtDolFFQVjIHCllC65t1POuXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=G2WPNkcw/AQArD/0fLhzGf/3OhLtWKdinrZM4lMUw4g=; b=QMxD+KSO9c+ku9XSZibcBUy6RcU1/17FyfsEKNd4LYGqfXeW3xznTipQjO1mnDcaQsFBhKQsdnvaeE1IJNVrbUkFfi1hSkRn7MmLh7/eD00ctMZTdKa2WDwdP5vyKoFkUfrwyQdovZ2ghBQiB1Xki2QLa87S+kvcJ2PWzuJl52B9483IQwX34w9qvlUn5U7U3QKj/D7MjHYWa1JTea6lLZU7LT6gV1bS855MAEiAvYbjJwHb5Tmm/qOBJb0GEUWTRYlO2j/hAuwNqPQrLbhpOQT9tatkjXnwzEU+CFrsikQJ5St3P6jQ6MDXQXGdJZleFYxavx4t7ygDwNCAxp8y4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G2WPNkcw/AQArD/0fLhzGf/3OhLtWKdinrZM4lMUw4g=; b=GotBz2NE7TgPOrPS43iMhs4cQ7XFE+bmpQb6tStv094DrLqlr4a2hN0DCjWCBi3j+qaYVpxVLLhNfmDzUi6JKUz1soUEWWmnuAd7ZrjUTljvR2RtFQZq0eWX5zuEMlU7ChLMcTbC8JlxU7ad8ys+iMxMjNdAtat/HWVw7BEAK3I= Received: from BY5PR21MB1506.namprd21.prod.outlook.com (2603:10b6:a03:23d::12) by SJ0PR21MB2069.namprd21.prod.outlook.com (2603:10b6:a03:398::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.3; Wed, 29 Sep 2021 20:57:15 +0000 Received: from BY5PR21MB1506.namprd21.prod.outlook.com ([fe80::c5e9:9018:e64f:c330]) by BY5PR21MB1506.namprd21.prod.outlook.com ([fe80::c5e9:9018:e64f:c330%7]) with mapi id 15.20.4587.007; Wed, 29 Sep 2021 20:57:15 +0000 From: Long Li To: David Marchand , "dev@dpdk.org" CC: "aconole@redhat.com" , "zhihongx.peng@intel.com" , "stable@dpdk.org" , Stephen Hemminger Thread-Topic: [PATCH 1/3] bus/vmbus: fix leak on device scan Thread-Index: AQHXq51PBlGQnBF6Lk6M+h/VMwY89qu7kUKQ Date: Wed, 29 Sep 2021 20:57:15 +0000 Message-ID: References: <20210917082313.21934-1-david.marchand@redhat.com> <20210917082313.21934-2-david.marchand@redhat.com> In-Reply-To: <20210917082313.21934-2-david.marchand@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=023e2a6d-317e-49ff-89a8-f2d6e594b9c2; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2021-09-29T20:54:50Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2e8c42ef-dc8e-432f-054a-08d9838bb7d5 x-ms-traffictypediagnostic: SJ0PR21MB2069: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 4I3EOyoJ4Ol3BtXhkD+pbi/qtuNswzv5GFlbYsD793kMBnbNzvp5DAoyHKG50fJpu4G/KyCTPRn/OPCuhLwkKhAb/MqcWYfWX7HKlFMKcF9gKVubEpIyMjvd4485MIBt6L/AR18TCQ1PpdDiXFJqopbbtLgB6fikAEaCFdprineL5uUkiqUWnyg27NPyMD7uDxTa0D6gMzdN8/2KzMePlEt0Q2U7OQdQvqRnczjWDxrCSsiGjrlH84eoLH4LjRYEX2lBAZc+qRF8mJ/pMs61ykhgld0ahNEDnGK/TAYcf8zpvd6zFEoJyv1RcZG3DM2w+q7PrIN0tT4lvvpf++RJYxDIRiPT7He6AOON6XBYUbQMSH82K9DRwvS3bDokFnx5LffX5wkbXP19d3ivOeeSfVWCurR5sdknHpl06BwIzUhBRrsmDMh61e2uJY0cpJ34EvTnlrgRu/1qwyEj++umf9EwQHbuX1gSGC34qI5AWjQXoL9rEyKzaP9wBrZqzp3R4XPqXfgfh2iXP+LHcZLUGG9WrJNM4RIy7sThc4nxXHemJ/uwW5ZUQTmrNNTzdm+qbyU4CVnr70AcJA/lLkTRgRh6GMxxnWqmCpc5iMT7kbTG9dF9pWYdh7EUqlTUyvJkcsgAzgZUsnCRvO4FO2y60FSM9ZhyjwYsOTL1O5EoYWMkgHWciAbChWQ/b4edI2LxOMUYAdlg+vKGVk4wpRMm0A== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR21MB1506.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(7696005)(4326008)(52536014)(38070700005)(38100700002)(8990500004)(33656002)(83380400001)(122000001)(5660300002)(66946007)(66476007)(86362001)(82960400001)(82950400001)(54906003)(110136005)(71200400001)(316002)(26005)(76116006)(9686003)(10290500003)(2906002)(186003)(107886003)(6506007)(8936002)(66446008)(55016002)(64756008)(66556008)(8676002)(508600001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?VthF5Wfp4OxvUp02dmzvFXSwlVdmcDxuPpnI5OIwfM5VJE80n1c9PRUMiQqx?= =?us-ascii?Q?4s/1K2x8Pzz8T8GkQttKFtpCUW3ZksG48RElPTaA2/EiP+pmUB8qY8bC5ajz?= =?us-ascii?Q?7j4wI0rX3eUP+v9qRPBLMhVGMj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Q?mikpfDZ9dV52qDPav/mQNnxJnkQ1E8VNjhbZqRuNhqiNn6/eOpIpG3jaW5To?= =?us-ascii?Q?sqmOoYWySLNcO5tmFZVEEebEkxTONxTXO8HFxHIQ5LsTVRAxtuOy21j9O2pV?= =?us-ascii?Q?wLpXyUbNy4U0nbHQ1RHUbWOGmdd8zif5W3AtwP8Us24pN3shRn4FOAI+LDrN?= =?us-ascii?Q?7DpoBV3gJdVCaNgunpY6WAh2bMwAji56tB6e5KFMcYMbfr5DEU8h8J1bnaeI?= =?us-ascii?Q?/QE8DnTFdY3gKTe1jsIJ3k4y64HmZjdsQP0eVL322B+gqsZQPtV9idWeMH8Q?= =?us-ascii?Q?F6M=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY5PR21MB1506.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e8c42ef-dc8e-432f-054a-08d9838bb7d5 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Sep 2021 20:57:15.6643 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 5HCMGzmqs/ixkGKN3vQ/ujrZYiHlUPM13af88F0QIuTyma1DfhsQ95Ikq3J1MKwThcmU6pRGE3I7ZnURmczviw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR21MB2069 Subject: Re: [dpdk-dev] [PATCH 1/3] bus/vmbus: fix leak on device scan X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > Subject: [PATCH 1/3] bus/vmbus: fix leak on device scan >=20 > Caught running ASAN. >=20 > The device name is leaked on scan. > rte_device name field being a const, use the private vmbus struct to stor= e the > device name and point at it. >=20 > Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support") > Cc: stable@dpdk.org >=20 > Signed-off-by: David Marchand > --- > drivers/bus/vmbus/linux/vmbus_bus.c | 5 ++++- > drivers/bus/vmbus/rte_bus_vmbus.h | 1 + > 2 files changed, 5 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/bus/vmbus/linux/vmbus_bus.c > b/drivers/bus/vmbus/linux/vmbus_bus.c > index 3c924eee14..d8eb07d398 100644 > --- a/drivers/bus/vmbus/linux/vmbus_bus.c > +++ b/drivers/bus/vmbus/linux/vmbus_bus.c > @@ -242,7 +242,7 @@ vmbus_scan_one(const char *name) > return -1; >=20 > dev->device.bus =3D &rte_vmbus_bus.bus; > - dev->device.name =3D strdup(name); > + dev->device.name =3D dev->name =3D strdup(name); I suggest not to add a "name" in struct rte_vmbus_device. How about definin= g a local variable in this function, like: dev->device.name =3D dev_name =3D strdup(name); If failed, just free(dev_name). > if (!dev->device.name) > goto error; >=20 > @@ -261,6 +261,7 @@ vmbus_scan_one(const char *name) >=20 > /* skip non-network devices */ > if (rte_uuid_compare(dev->class_id, vmbus_nic_uuid) !=3D 0) { > + free(dev->name); > free(dev); > return 0; > } > @@ -312,6 +313,7 @@ vmbus_scan_one(const char *name) > } else { /* already registered */ > VMBUS_LOG(NOTICE, > "%s already registered", name); > + free(dev->name); > free(dev); > } > return 0; > @@ -322,6 +324,7 @@ vmbus_scan_one(const char *name) > error: > VMBUS_LOG(DEBUG, "failed"); >=20 > + free(dev->name); > free(dev); > return -1; > } > diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h > b/drivers/bus/vmbus/rte_bus_vmbus.h > index 4cf73ce815..438eb481fc 100644 > --- a/drivers/bus/vmbus/rte_bus_vmbus.h > +++ b/drivers/bus/vmbus/rte_bus_vmbus.h > @@ -65,6 +65,7 @@ struct rte_vmbus_device { > TAILQ_ENTRY(rte_vmbus_device) next; /**< Next probed VMBUS > device */ > const struct rte_vmbus_driver *driver; /**< Associated driver */ > struct rte_device device; /**< Inherit core device */ > + char *name; /**< Device name */ > rte_uuid_t device_id; /**< VMBUS device id */ > rte_uuid_t class_id; /**< VMBUS device type */ > uint32_t relid; /**< id for primary */ > -- > 2.23.0