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 2EF6145634; Wed, 17 Jul 2024 13:05:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6DA20427D6; Wed, 17 Jul 2024 13:05:03 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by mails.dpdk.org (Postfix) with ESMTP id 9115E40395; Wed, 17 Jul 2024 13:04:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721214298; x=1752750298; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=KRP6tdxZyRBqh5dwig/O5IAs/tFcIP8eCGGkMxVqiAs=; b=EivtfAUv8kCHF0+oAw11iPXA+JdgVVUThOhT0VV+pUlDRat9uDjMduIj nIn5RwQQ2zwG4A9pp4RPtYx8h6elXV0T+u7tsp24qEnxQJMS7hsNWoY5p gx4+tcXI/6k6Pkp5V11PTZvCx75vtb9Hc3Z3cleYcCyce5b0wjB7UmB/R SzCEM15tS1pCUxsv4NX0WF2iZI1v081+9fTtPxK1tqdI4FipJcx5Xf3Sf h4lzHjd00K5+cscYn9EKNP0MhWtGirIachzuQH1U24fVymA1W3X8kuR7z Oa+AyduolnGowmQHs4j9yOdPuf5je1d5ChJFf9lKOrdn/31VczsTHYFoO w==; X-CSE-ConnectionGUID: B0KO1iPWRLa8bi17/Kht6Q== X-CSE-MsgGUID: 13lfA6ZzQ+6wBf5Q7G+Cjg== X-IronPort-AV: E=McAfee;i="6700,10204,11135"; a="18839101" X-IronPort-AV: E=Sophos;i="6.09,214,1716274800"; d="scan'208";a="18839101" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2024 04:04:50 -0700 X-CSE-ConnectionGUID: T27QUY1pSSiCYME+795UEQ== X-CSE-MsgGUID: F7Ao7S64QsK0AjIHVxoc8Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,214,1716274800"; d="scan'208";a="50252118" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmviesa008.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 17 Jul 2024 04:04:49 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 17 Jul 2024 04:04:48 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Wed, 17 Jul 2024 04:04:48 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.47) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 17 Jul 2024 04:04:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nmEwDWtCIr3keLaL2lDC5QhKyypaq9MsqCgg1VilnmBcybzhKfhzINw65OmmD6mwV42+uu1PLkgx9pQI0/TG48aVvI9mhfXPIoOT4gb2W60cID6ZoOeJMWpFrGlq+lJiREr4RGwbOWx1GCH+Oz2MSV34COeW2F8AuIKbLutdzJHMAWQNM4Z79NTE7ufAmB8ypLlNuQbrOf1zyizk0ws35GdJy6Eb2KIdokjJ/9g/RlvvUvQ0sQkHWHxhDPHkKl2pBvGqx64cBJoL+NWCbXinBObZEMQXABujkqQoOQs+5/H550HA3DkVN1BOUDGICTTv70Q5HD1x04EdGoV1atowAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=UDQAANgm8Z6NSLU9VNUVs3wyc2vHCinEN58cT8MuRbo=; b=SkeIt4w3NQ4dI1kHdNMQUyAlmKaiq2JLuAQ8KT40/dJ46o9QXNDT9i3CV2sIYA9+OWkS+08okROCTc2064Fr49HesMnH+oGa3+x2diHaqPZIJRN0iC+owUDejzQxgFsyZduS63o6QW34xZ3VNghJ89f0AcyKEBSBXqjrAZOIcuOgbxiZwLx39V5D7ArAfh+GIlOd+PCzzwEHHrEFCm1SKi9axi5+mrA1ZIw0h13t+tWyk89Zljmlci5GbaOQ04LSFRIDaNT8WInoiaNBpV+o/C38v7D9fS5AjXcJq7sEyfa751uy+luXdfu+tIhCc/FWupVAEhTXDKM84OuVxi7jdg== 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 DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by MW4PR11MB7077.namprd11.prod.outlook.com (2603:10b6:303:223::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.25; Wed, 17 Jul 2024 11:04:45 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b%7]) with mapi id 15.20.7784.016; Wed, 17 Jul 2024 11:04:38 +0000 Date: Wed, 17 Jul 2024 12:04:33 +0100 From: Bruce Richardson To: Vladimir Medvedkin CC: , , Michael Theodore Stolarchuk Subject: Re: [PATCH v2 1/3] net/ice: fix possible memory leak Message-ID: References: <20240711165907.3169191-1-vladimir.medvedkin@intel.com> <20240715180441.3682734-1-vladimir.medvedkin@intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240715180441.3682734-1-vladimir.medvedkin@intel.com> X-ClientProxiedBy: DUZPR01CA0079.eurprd01.prod.exchangelabs.com (2603:10a6:10:46a::16) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|MW4PR11MB7077:EE_ X-MS-Office365-Filtering-Correlation-Id: a7536e2b-f603-4cb1-bbcb-08dca650404b X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?nTe45ccaWd7P0Jwfhj3mCVp+pEa6PFT/26G5XbM04P7EYit5ozAhKZFP9GdJ?= =?us-ascii?Q?Dlz5ryY2qCusjVYC9yLruOf84L7M5C2F/0NRwJGsO/VcR9Dlu2wC8K1qdVYe?= =?us-ascii?Q?9N44+Fecp+urlJsczCjLhUQCVTP2aFz7/TTMiVLaLbHUmlY9E+2u35PzcIRw?= =?us-ascii?Q?62SYGi5WVRZiM2abboH3MKfBenQkg5LqD2GSNE6pKBlqCkzYhdWREM3j4XEd?= =?us-ascii?Q?v5baaD6NKKymXnEmVxPkSiYqG3wOa4P//6E9gLhR0X80kJ7BPBtIgw8tLV0R?= =?us-ascii?Q?VSGQSUNr7OhlwIsTVYAtJKh+VGR2jHKH8OBKyRSa16v2MXpiZvZqTJ0VxwcZ?= =?us-ascii?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BtfMEnjiZU5DlhD?= =?us-ascii?Q?6XEoy1uchyE8HmtEmqE+6BpiyVA7K56CNElJdjd6LvbO8JtsGoBwQW18ShvV?= =?us-ascii?Q?WczzwefRvcNMcDJEPty2P2mmuDyEhmmByovkT+XQcgeT/A=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Q+bhDj5YjZmUWJvvjoJ4tTQrr32ykkK78MNMuh5IlgtT+zDhg1T7gBtUnlLi?= =?us-ascii?Q?pOnfEWmr8xIj5aK38rprNr/WhvymPCmrg9930A6ZhvNU1BHPzLtYwYl3YCdU?= =?us-ascii?Q?QPje6+OxHbab/gf9c4EldNQD7QUoHhvPbHjL4JaAD7+yTKQ6OyTnIf6F34zk?= =?us-ascii?Q?IVjlh6A28IhweENdw2osHVN2qaAIJN7ZVcyQgrTUACKVA2N71cR3IXimXCDx?= =?us-ascii?Q?kY9pc9TKBJpwmPafrLnEcAGvGVUnQL0VkKoK2fCenuctzsPPgwxwjd2drmPA?= =?us-ascii?Q?93iiuk/I8ntgKS5opyUSvTlJ1VKxr1cVZ+L1SRyrI9fJkT3+fiXIrxd5VkxL?= =?us-ascii?Q?xgBpdVrdoaR01LszZsogb8Szr/kYr5PBEmtCkLNDOEUboAoJzzh34dSuK9A/?= =?us-ascii?Q?ZnL4F9ulrUuMGT0y8vR+biuqlKFEN+W/KO9u0zGh9ngpZC/IHMTMBzoT0VAh?= =?us-ascii?Q?Pq3Z9RaizkXfJQNc9ksHrPxSw4t3fUF+ce4T4FvAePxueW7p8BsOCcPovvMf?= =?us-ascii?Q?v9zNJyZ/LdKfhHpMxsD5C3dz2IDa/w0t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4cjSNkfMduktVS5KdZpUwTtUOt4uTegzUzuQDuCAl9/isMNUa/dTAqpP?= =?us-ascii?Q?w91Fa5YRtrwwsj30ZojwhlvGSbQlvHhEYVQKma7SPP1//eTQuV2XzZuRjUei?= =?us-ascii?Q?224j9OEcrnF5WifC3AibSSkK5vnGQkrwVMoEhn+RdnmnP+y93iKdcNKu/LAV?= =?us-ascii?Q?5A=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: a7536e2b-f603-4cb1-bbcb-08dca650404b X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2024 11:04:38.8533 (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: +R9jLcpWD6R0zUzKvcQCbtmTiB/WN8tuUvpDmzsQaRF6xk9qK45bYrRYAPDj4p094xiD1pT9H1kn7TCLaFBSeOF3k3xuGwnRwlZPcNuOc5w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB7077 X-OriginatorOrg: intel.com 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 On Mon, Jul 15, 2024 at 06:04:39PM +0000, Vladimir Medvedkin wrote: > This patch fixes possible memory leak inside the > ice_hash_parse_raw_pattern() due to the lack of a call to rte_free() > for previously allocated pkt_buf and msk_buf. > > Fixes: 1b9c68120a1c ("net/ice: enable protocol agnostic flow offloading in RSS") > Cc: stable@dpdk.org > > Reported-by: Michael Theodore Stolarchuk > Signed-off-by: Vladimir Medvedkin Hi, comments line below. /Bruce > --- > drivers/net/ice/ice_hash.c | 19 ++++++++++++------- > 1 file changed, 12 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c > index f923641533..913f54fca4 100644 > --- a/drivers/net/ice/ice_hash.c > +++ b/drivers/net/ice/ice_hash.c > @@ -650,7 +650,7 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, > uint8_t *pkt_buf, *msk_buf; > uint8_t tmp_val = 0; > uint8_t tmp_c = 0; > - int i, j; > + int i, j, ret = 0; > > if (ad->psr == NULL) > return -rte_errno; > @@ -670,8 +670,10 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, > return -ENOMEM; > > msk_buf = rte_zmalloc(NULL, pkt_len, 0); > - if (!msk_buf) > + if (!msk_buf) { > + rte_free(pkt_buf); > return -ENOMEM; > + } > > /* convert string to int array */ > for (i = 0, j = 0; i < spec_len; i += 2, j++) { > @@ -708,17 +710,20 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad, > msk_buf[j] = tmp_val * 16 + tmp_c - '0'; > } > > - if (ice_parser_run(ad->psr, pkt_buf, pkt_len, &rslt)) > - return -rte_errno; > + ret = ice_parser_run(ad->psr, pkt_buf, pkt_len, &rslt); > + if (ret) > + goto free_mem; We are losing the error code retrn value here. I think the final return in this function should be "return ret" rather than "return 0" so we can propagate up the error. > > - if (ice_parser_profile_init(&rslt, pkt_buf, msk_buf, > - pkt_len, ICE_BLK_RSS, true, &prof)) > - return -rte_errno; > + ret = ice_parser_profile_init(&rslt, pkt_buf, msk_buf, > + pkt_len, ICE_BLK_RSS, true, &prof); > + goto free_mem; Same here. Also the "if" statement before the "goto" is missing. > > rte_memcpy(&meta->raw.prof, &prof, sizeof(prof)); > > +free_mem: > rte_free(pkt_buf); > rte_free(msk_buf); > + > return 0; > } > > -- > 2.34.1 >