From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63E5AC433F5 for ; Mon, 7 Mar 2022 00:28:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234484AbiCGA2t (ORCPT ); Sun, 6 Mar 2022 19:28:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231548AbiCGA2s (ORCPT ); Sun, 6 Mar 2022 19:28:48 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7116A1CB31; Sun, 6 Mar 2022 16:27:54 -0800 (PST) Received: from [192.168.43.69] (unknown [182.2.38.152]) by gnuweeb.org (Postfix) with ESMTPSA id ACDC47E6B0; Mon, 7 Mar 2022 00:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1646612873; bh=6EwZV+kp79HnWRono9OuMB+/b/YqdJWhwy0MRnJZHtY=; h=Date:From:To:Cc:References:Subject:In-Reply-To:From; b=OTuJ6ILo75TBX/uZWnLWFfWoG8Cigsi04UWES0JH2WMsuoWeC548ndDlhZjMiyhhu W6x5ojLiZ/CVxJEi+MEtziuaxgysHmiuI8yL13nOL2HFg5bPTzsBWf6Zr5mIN2Ourq qqZ2FZ58goycAu63b6QJxFuhmoZ2BCg3RW6Nhd2uOWytgIZ3iOY7DmEVmTESIopmaj /yO70vGKO/NmYR4YBmDcveIhNUvDUfvEmXxT+lvuA/fNQnkh1fkOdKUjoYvjgbGux9 /QJvwFp1+VZaCjvKU9qmf6KOFTf+KdBJGWRgvIaEOcApwFQvNJhSAwnlUeyeYq9+rp i9cr+nVpPOzyA== Message-ID: Date: Mon, 7 Mar 2022 07:27:44 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US From: Ammar Faizi To: Yazen Ghannam Cc: Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , Tony Luck , linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, gwml@vger.gnuweeb.org, x86@kernel.org, stable@vger.kernel.org, Alviro Iskandar Setiawan , Jiri Hladky , Greg Kroah-Hartman , Alviro Iskandar Setiawan References: <20220301094608.118879-1-ammarfaizi2@gnuweeb.org> <20220301094608.118879-3-ammarfaizi2@gnuweeb.org> <4371a592-6686-c535-4daf-993dedb43cd4@gnuweeb.org> <109a10da-d1d1-c47a-2f04-31796457f6ff@gnuweeb.org> <20220303015826.4176416-1-alviro.iskandar@gnuweeb.org> <49313736-61f8-d001-0fe4-b6166c859585@gnuweeb.org> <9dfe087a-f941-1bc4-657d-7e7c198888ff@gnuweeb.org> Subject: Re: [PATCH v4 2/2] x86/mce/amd: Fix memory leak when `threshold_create_bank()` fails In-Reply-To: <9dfe087a-f941-1bc4-657d-7e7c198888ff@gnuweeb.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/3/22 9:32 AM, Ammar Faizi wrote: > It looks like this now. Yazen, Alviro, please review the > following patch. If you think it looks good, I will submit > it for the v5. > > From 91a447f837d502b7a040cd68f333fb98f4b941d9 Mon Sep 17 00:00:00 2001 > From: Ammar Faizi > Date: Thu, 3 Mar 2022 09:22:17 +0700 > Subject: [PATCH v5 2/2] x86/MCE/AMD: Fix memory leak when `threshold_create_bank()` fails > > In mce_threshold_create_device(), if threshold_create_bank() fails, the > @bp will be leaked, because mce_threshold_remove_device() will not free > the @bp. It only frees the @bp when we've already written the @bp to > the @threshold_banks per-CPU variable, but at the point, we haven't. > > Fix this by extracting the cleanup part into a new static function > _mce_threshold_remove_device(), then use it from create/remove device > function. Also, eliminate the "goto out_err". Just early return inside > the loop if we fail. > > Cc: Borislav Petkov > Cc: Thomas Gleixner > Cc: Greg Kroah-Hartman > Cc: stable@vger.kernel.org # v5.8+ > Fixes: 6458de97fc15 ("x86/mce/amd: Straighten CPU hotplug path") > Co-authored-by: Alviro Iskandar Setiawan > Signed-off-by: Alviro Iskandar Setiawan > Co-authored-by: Yazen Ghannam > Signed-off-by: Yazen Ghannam > Signed-off-by: Ammar Faizi Hi, It's Monday morning... Friendly ping for Yazen from AMD. What do you think of this patch? If it looks good, I will submit it for the v5 revision. See the ref below if you lost track of the full message. Ref: https://lore.kernel.org/lkml/9dfe087a-f941-1bc4-657d-7e7c198888ff@gnuweeb.org/ Thanks! -- Ammar Faizi