Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1755201pxp; Mon, 7 Mar 2022 01:30:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzgF7236RhtcbEo1ICtFWRMHZX5ZNEvswvhcxpNPX0v0yhpFCWycQ3j0hKnIlKRyKE+O4Pc X-Received: by 2002:a50:f1c9:0:b0:415:a0f6:147d with SMTP id y9-20020a50f1c9000000b00415a0f6147dmr10184855edl.247.1646645433443; Mon, 07 Mar 2022 01:30:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646645433; cv=none; d=google.com; s=arc-20160816; b=sxf8mqO1vQAklNstzdHzWkGOIqrVDl3ppuvRqq3Nz+WTMteU0acYQAqksv1ke1GxlK okfcSbQPeciMDCIjoFDJ4GxFfzVM8B7aVNC7MU26h/GZFpNsIHtBtJJEusWAQccWPUWH 9zsEVm6YFnsnkMRK26HDdD+mb88j3okorfH4vMyqNuwlwAU2YwH+ztVAyLEBLtLvmV/m 8z/P/OMnRxJ35pcZA9WwhMKFcZn+ytcUEC/BENVo8V5cXx1+s3FQD5GDCzZW7u0mdpmq DOVcWv0CsWzXHTcTf67ZcPoeA5Eu/C7E4UNvhhfOuctr1yJMxXqEFeSsxCXbIuZL6kGL ZFBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :references:cc:to:from:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=ryDssvthJIfgkoJ1yKbwVQESZOAY2g5WnNY/I1uyjwg=; b=B6aG2VoXA1iOcY1jcmM8aTR7z4E7+fFpTiejUnaLFAudxZwoxteb6U4iXT/Fb2DCm/ rcBtyjFqpLi+dg9qXMHVpw0bpkEWoZlX9Eh5P6bcyn/7N9EAXyvHYMFk29nU1u+Q5Inm JIITdMRUz+iyDsUCrWGVp2IjBeOAhQIkRKEgJDkDuIHQVSN64VDYskAI9xqs50l0pGDv RCcN8zjchYpiGCXvOBesl25bjyEchhf5n0QAIYjx7vJuUkdckZNlaLBhIpshBDcIyGu4 tZRID8ti8I5Perxx0+WElUmob8P2r6VZsR0uMCxDq6zy2+2baEvhpDauH3OY5D1R/xoY sFlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=OTuJ6ILo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc40-20020a1709071c2800b006db2c850037si2252806ejc.583.2022.03.07.01.30.10; Mon, 07 Mar 2022 01:30:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=OTuJ6ILo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234367AbiCGA2t (ORCPT + 99 others); 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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