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 61B5DA00C3 for ; Tue, 19 Apr 2022 18:20:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5A3914113C; Tue, 19 Apr 2022 18:20:15 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 549EC40687; Tue, 19 Apr 2022 18:20:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650385212; x=1681921212; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=36uewIMAS7q4OJsWB0IVoImub/F4k6eE5Vb7P0bMSvc=; b=ikwD3zn33ee1XkoCP59jLc6TmPliDfSlgIOV8qgLNV1E5Z5sd2H7H139 z7WdbMnaBx8cUBzVjnXYXuvCFAOP3ppHKRZ7cJ+qqWU2IdGY2N0HCHXFD TZOP9hcpwJnkpHrafNCnCJxXsHkTe+E7fKsMeNJduV7CF+2LCyCksnWIa cA/9SjjHzK/ET5IKbnqK/5OEOLt51JLh8N/qiupoe90OJhVVwc8eY10yH 7EJJdX4xDygwg9wGPbYSllXAjTB8GNyIlL0u2cg/+TcgFqELUlcUQXJae Wo5wG9o+pxKqRL1unlxDXOBdQlJATQi3IAjdlJvHalSfQjTnDcmgT2DXR g==; X-IronPort-AV: E=McAfee;i="6400,9594,10322"; a="263566460" X-IronPort-AV: E=Sophos;i="5.90,273,1643702400"; d="scan'208";a="263566460" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2022 09:20:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,273,1643702400"; d="scan'208";a="702238687" Received: from orsmsx606.amr.corp.intel.com ([10.22.229.19]) by fmsmga001.fm.intel.com with ESMTP; 19 Apr 2022 09:20:11 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 19 Apr 2022 09:20:10 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Tue, 19 Apr 2022 09:20:10 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Tue, 19 Apr 2022 09:20:10 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L4NIOuURA9X53yvYs9yR5nTpom8Fi1wZbT+CbyqT7O9MresLeRZKFQBwMVOJ3W7B75OVut8KWsDGl25ox1mqYKD4i5VjQqZcKMwhrvNwLYVAQsgGyQ/hcCw0OUCG/odd9ysLlhUYC8zg2jisfeUeaQCrO4FSd/46bW6ex49oWgqjVWCQ0BOG0gwv1IZoCMDsKXcxnVh6y88clXq27FVCUjxy2lNPHGzm4tyshsdKGp4dxVdmgODhtmHdV4bE47+VRaHpcJtBKz/by1Q5vuHAHlZrFbnm7WNDBnl+2nqvUBh9Efn/Ar7gZmsfWDiBFsSFMfI2PMe5Ko4IP1b3rU40Qg== 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=zdQFj88qXbW6sSmDZ7PViJ7nEWX+XLghdLqekNDTKbk=; b=h+/OHcQdTtpVcRF8cMIzBQgO0wqVg+bP9KZU9MqB5EHrLwKOngtV5hBxp8Tv2Iqkf/TEQv8xVGK1gIQHGgLQawMnuX4IUl+gRz2Jw9FPBUXaC6DUqYUSUDIsNDsv1BM9QScW4/t0tNUbnTBTeTc8BYERGs610XF/6qlDcCsBE++NWds3qoX+ux1jA6/bGxVihNBPQRLx7sYL4C+tJ3v5CihOzYkdb5hhoNYAatnatPbpCh3a3xuNJqIsjAfBlyHCXm4nx4uNdaWUEARMIz7kbUXs+4lmQcuXJrwnj0I5gH6RjTh3kAxJG7g19FCIvrsKofEthyRsNpSVGb0vnJBGCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MW4PR11MB5872.namprd11.prod.outlook.com (2603:10b6:303:169::14) by MW3PR11MB4618.namprd11.prod.outlook.com (2603:10b6:303:5f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20; Tue, 19 Apr 2022 16:20:08 +0000 Received: from MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::d55d:28c1:bfab:3dd]) by MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::d55d:28c1:bfab:3dd%5]) with mapi id 15.20.5186.013; Tue, 19 Apr 2022 16:20:08 +0000 Message-ID: <252628e0-a7d5-edf3-170b-0d35318b43b7@intel.com> Date: Tue, 19 Apr 2022 17:20:01 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 2/5] dma/idxd: fix memory leak due to free on incorrect pointer To: Bruce Richardson CC: , , Conor Walsh References: <20220408141504.1319913-1-kevin.laatz@intel.com> <20220408141504.1319913-3-kevin.laatz@intel.com> From: Kevin Laatz In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LNXP265CA0056.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5d::20) To MW4PR11MB5872.namprd11.prod.outlook.com (2603:10b6:303:169::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c35e9e6-2f48-4c65-ce4d-08da2220782d X-MS-TrafficTypeDiagnostic: MW3PR11MB4618:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fILN5zspI28c16c5NdZs+T4QULK7xh4fY0WIUTQbvE9oUdUHlfjWxL3aHGgEWJ4PAL+kJMmAOnZKytaV87EkuFuoe0/F+ASh3t0N0+L92+mgXVRRGWUzWLwQcvXE7gYmKyJEOXzbfDFSN1MbgOv+Ca2Q3ui8PzFyb2JnOxab2Hztbj82EEkET9N8N2DBEp5u6PN9FS0vpchYuY2KWpwJoZsLwi7yy39S3avjm8OoRkQaDZfEUUSX89OwvKxXI5kUpmMYIkzd47Ag3saRMsXYk2U9qXy2zDSyol1xb+bd9bA0hmrgrt7ulQyL+a8KAjd5K9gDKWsmz0CL2hcDUw/za8tvMz8/k4yrrNdItuubIGZqtZLbJlZNkTsf6CXMTRsRDldPeXzzryj1DqlxcdPB8u63Ml0Q83MyBsktM0SFD7p6DXsjzrsEEa2HVri3DQTf1ENiSeoLd6J5fzUY1xKIEst01QQn7L1Q9iR/vdcuoWQvxAb5aTOEYtYJElnI57hnzD++5aKP5pebf8ccVNDxSH/yw69yD5FSXX7oh31kCGu0BbvjZpxB+fc8AQcoJjmJrem1/6xu3xckSbF5gJX1DMOV29Php0BYWuQ+Z8b45y0mf1SZC15dOfK8ozUs7VWldDs9lWF7z/0yzLtd9tY6LSbMc1Oz0nfXKruLguz2IZWyH2ezkb/KIkSkjtGpJ7osEHuOsLuVwtty9WjtUcSqBvz9CaI4/0UmNFVA9XRE+H4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW4PR11MB5872.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(82960400001)(5660300002)(4326008)(508600001)(6862004)(6512007)(6666004)(186003)(6506007)(8936002)(450100002)(83380400001)(107886003)(38100700002)(44832011)(2616005)(31686004)(36756003)(66556008)(53546011)(8676002)(26005)(2906002)(66946007)(66476007)(86362001)(31696002)(6636002)(316002)(6486002)(37006003)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Wlo3OUNoRDI4eXowVHpVZDZlcXVBWEpOWHBvdzdpZEV0c2JrL1VqckwyQlZL?= =?utf-8?B?MEJUeEdLWWlpa2dlb25odlRHVGhDNHlaWUM1blpiU1NKUDRrOEpySWZ2cFNn?= =?utf-8?B?OUk2LzU0OFVDa2ZhMlIxRjRydG9qaG0rOGR5WExNbHgxOWdUdVQ5WWtLN0M3?= =?utf-8?B?T2JEcjBrSDZzQ2EzY3d6N3BpUGl1dnowVkpnNjdQS3FNWnJzRE1BWG1vOFJM?= =?utf-8?B?MDVzYUM5TXM3VjUzNVc4UEhseko0Z0NTSjQzL3A1S3Y0d3lBV2F3SXpKVkc4?= =?utf-8?B?VEYzazY3S1R3Q3BkQnJ3QlVJcWtYUDZMMkVyRlRHYkx4TWk0cW1WWUQwa0pO?= =?utf-8?B?ZWdxWHpuQjI5YVJDcGx5QVVvb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zlLQW5ZNlBiazlK?= =?utf-8?B?dnprS09NUm1hRHhrVnNTeDFIMTFlZiswTG82NWZrbG1SMmF5NFN3QnJGbWRN?= =?utf-8?B?M2lGOU4xMzlhTlIvYVIwYzRFMXNHUzAwVC9odmpLZmdTaFBJY29KK3FsMkgv?= =?utf-8?B?dDJBUXRQbTZnV3lMYzdnRzU2MGM4VEdoczlIcmVXb2Z6dFhURkFXQT09?= X-MS-Exchange-CrossTenant-Network-Message-Id: 9c35e9e6-2f48-4c65-ce4d-08da2220782d X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5872.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2022 16:20:07.9411 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7IXAVC1mZhuuc2fAcUAv03UjUwNjmMI78KBe9st/uwbyW5k3qGmP30bDVYpcZw7GeL5/Gc5FEVf4qmg7DwzA8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4618 X-OriginatorOrg: intel.com X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 On 08/04/2022 15:52, Bruce Richardson wrote: > On Fri, Apr 08, 2022 at 03:15:01PM +0100, Kevin Laatz wrote: >> During PCI device close, any allocated memory needs to be free'd. >> Currently, one of the free's is being called on an incorrect idxd_dmadev >> struct member, namely 'batch_idx_ring', causing a memleak from the >> pointer that should have been free'd. >> This patch fixes this memleak by calling free on the correct pointer. >> >> Fixes: 9449330a8458 ("dma/idxd: create dmadev instances on PCI probe") >> Cc: stable@dpdk.org >> Cc: bruce.richardson@intel.com >> >> Signed-off-by: Kevin Laatz >> --- >> drivers/dma/idxd/idxd_pci.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/dma/idxd/idxd_pci.c b/drivers/dma/idxd/idxd_pci.c >> index 7036eb938d..fdb1f15750 100644 >> --- a/drivers/dma/idxd/idxd_pci.c >> +++ b/drivers/dma/idxd/idxd_pci.c >> @@ -130,7 +130,7 @@ idxd_pci_dev_close(struct rte_dma_dev *dev) >> >> /* free device memory */ >> IDXD_PMD_DEBUG("Freeing device driver memory"); >> - rte_free(idxd->batch_idx_ring); >> + rte_free(idxd->batch_comp_ring); >> rte_free(idxd->desc_ring); >> > This is largely my fault, I expect, for being "smart" and allocating the > memory for both arrays from the one allocation. To clarify things, we need > to: > 1) update the commit log message explaining why it's the wrong pointer, > i.e. that the two are in the one memory reservation > 2) similarly add a comment to the rte_free call noting that it frees the > idx_ring too. > > Alternatively, we can also consider adjusting the allocation code so both > arrays are allocated separately, and on free are freed similarly. We would, > however, need to double check that doing so introduces no perf hit. > I'll add explanations/comments where needed in v2, thanks for the feedback. Kevin