From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E4CC25EF90; Mon, 24 Mar 2025 12:51:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742820681; cv=none; b=KgCFkt1BKhVjPViLtihS8caT/6sEenpMwQs3o7ZhWajAUb2PjiFpFLOwzy7USQLPNO5cEv4ZJZQlQJW1njdsHKFUKo5meOuBq5mCzSQSpZocqkfpuhm7TJVHiSbu7t7cWRBoVJkaC5JkU1fStJbgyB19SM98YPxS5DBwLkSuypM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742820681; c=relaxed/simple; bh=SskKo6BEXqjWismZvLLpJ50BS/HyqQjryM3kuO4JNZQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oMnuKPxoB7eevc/hC7iWnY/EgXEh2BxZTSFKb5TJAgLlmnz12s2Om3p18PJzmjvXrxMTCb05enlhtb0UjfrxnXTgnX2PA9SsrqqbBL44/Ai8N6wMGTffgvu8Jd+RzV9n/YIUYL4vXnjA+mH9+etZKGnat0GTBUhxgT5DU69hE+k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=aeJpHzaf; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="aeJpHzaf" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=I8xvSTrF+CLj7ibckfWAmAEUfTSv6VxXJGkoERVw5mQ=; b=aeJpHzafuJzRiuIf+GMnlKs3z1 3/ZEeienyTdidSujp1qb47Li5I4tSrols2bHwGRikoJ1yWBa2Tpf/3u2VPhG8nqWN0TGXeewvsfTJ deLuRo+pkgztXbwcTgdgyLrvF1SGtDjkSFSjyvf2k5FH3jn7uAy3V2y0pts/SW6iZxcPHgAYdd8EW SkD6Bee0IcPvmI0yzjl3mlNWPQOc/KdFaYD7KY0l+fIuat++A0T41vU9/bJpS4rZsqPebfANwDREP 4ZVWNN7nTp5hCyLWrOGMUU838Dl3y3UOIWG0s8L3XjnptAs/4VvvV3fhJaTsF1mBMOJezgnPIRlny IbNHE+Xg==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1twhGn-00000000g68-1nyj; Mon, 24 Mar 2025 12:51:09 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id AFEC93004AF; Mon, 24 Mar 2025 13:51:08 +0100 (CET) Date: Mon, 24 Mar 2025 13:51:08 +0100 From: Peter Zijlstra To: Malaya Kumar Rout Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH] selftests/x86/lam: fix memory leak and resource leak in lam.c Message-ID: <20250324125108.GH14944@noisy.programming.kicks-ass.net> References: <20250324124810.883767-1-malayarout91@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250324124810.883767-1-malayarout91@gmail.com> On Mon, Mar 24, 2025 at 06:17:50PM +0530, Malaya Kumar Rout wrote: > Static Analyis for bench_htab_mem.c with cppcheck:error > tools/testing/selftests/x86/lam.c:585:3: > error: Resource leak: file_fd [resourceLeak] > tools/testing/selftests/x86/lam.c:593:3: > error: Resource leak: file_fd [resourceLeak] > tools/testing/selftests/x86/lam.c:600:3: > error: Memory leak: fi [memleak] > tools/testing/selftests/x86/lam.c:1066:2: > error: Resource leak: fd [resourceLeak] > > fix the issue by closing the file descriptors and > releasing the allocated memory. > But but but, doesn't the program just exit on any of those 'errors' anyway? That is, iirc this is a single shot program.