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 F0361A0032; Sat, 2 Oct 2021 18:25:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4226441205; Sat, 2 Oct 2021 18:25:07 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id A6C854122D for ; Sat, 2 Oct 2021 18:25:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633191905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LFF1BeAqQwlJJJ95Bm8Q8YGvb0zCTwNq+Qte80Wy9HE=; b=A6JaYG3Ai1SyGFT9FTP8Skv2+ip6YtC8qFO4S2/KlDS/tRFMewG8HkpprTQXO/kpzrclap p1W2I5JFA1n4HF3mZVGwrYPhsJMNo3XnQjXRkB/1o/DrTRaxirPHDOhWyq+rLytjfqnksc S3g2IUyewBCgNNcR9PgANF7d+/hZIw4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-584-Ev-6ZHwOMRudsGCX4ctT7Q-1; Sat, 02 Oct 2021 12:24:48 -0400 X-MC-Unique: Ev-6ZHwOMRudsGCX4ctT7Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 16911801FCE; Sat, 2 Oct 2021 16:24:47 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.194.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C6DB5C1D0; Sat, 2 Oct 2021 16:24:44 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: aconole@redhat.com, zhihongx.peng@intel.com, stable@dpdk.org, Stephen Hemminger , Long Li Date: Sat, 2 Oct 2021 18:24:30 +0200 Message-Id: <20211002162432.4348-2-david.marchand@redhat.com> In-Reply-To: <20211002162432.4348-1-david.marchand@redhat.com> References: <20210917082313.21934-1-david.marchand@redhat.com> <20211002162432.4348-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH v2 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" Caught running ASAN. The device name was leaked on scan. rte_device name field being a const, use a local pointer and release in error path. Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support") Cc: stable@dpdk.org Signed-off-by: David Marchand --- Changes since v1: - left rte_vmbus_device untouched, --- drivers/bus/vmbus/linux/vmbus_bus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/bus/vmbus/linux/vmbus_bus.c b/drivers/bus/vmbus/linux/vmbus_bus.c index 3c924eee14..68f6cc5742 100644 --- a/drivers/bus/vmbus/linux/vmbus_bus.c +++ b/drivers/bus/vmbus/linux/vmbus_bus.c @@ -236,13 +236,14 @@ vmbus_scan_one(const char *name) char filename[PATH_MAX]; char dirname[PATH_MAX]; unsigned long tmp; + char *dev_name; dev = calloc(1, sizeof(*dev)); if (dev == NULL) return -1; dev->device.bus = &rte_vmbus_bus.bus; - dev->device.name = strdup(name); + dev->device.name = dev_name = strdup(name); if (!dev->device.name) goto error; @@ -261,6 +262,7 @@ vmbus_scan_one(const char *name) /* skip non-network devices */ if (rte_uuid_compare(dev->class_id, vmbus_nic_uuid) != 0) { + free(dev_name); free(dev); return 0; } @@ -312,6 +314,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 +325,7 @@ vmbus_scan_one(const char *name) error: VMBUS_LOG(DEBUG, "failed"); + free(dev_name); free(dev); return -1; } -- 2.23.0