From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6475B2F12A1 for ; Mon, 3 Aug 2026 21:59:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785794381; cv=none; b=cupC2ZcI5hLgY1CNvXz1pN4Tl9B+d/K9f4kt9iag4+qNdaYxuWDypVX+snyCd2kSryOLHxk2Bpeptz7wOHvbymHdLKBtk8tVVmTgJpzl3HkL2jRkkinqFlzsIcUwdTwqn5NcROaVlR6BZcghXDr9n4CByjQgwJ+DAlpJrRcu0XE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785794381; c=relaxed/simple; bh=R1EzwM0iGQZ03G4a5hqC73Y0K499jeEQ4KP6FVLTvjI=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=S5TP2JCKsERoWuKewuWgQaxlAfd8PtKhxGLJi7l+db/MyA/9yVV1wWydkfV4mGtEuPsZnu4hQmn12F2z8RSwyuTAvEybWD1kLcpEx4CB6aEoAgE+LM9MrheEP/LH2yaCdvr9hnMX2oITx8clxcRhSkSTFFm3M4wpK6+lMkid72w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--rathodpriyank.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=I4WxpEK+; arc=none smtp.client-ip=209.85.216.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--rathodpriyank.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="I4WxpEK+" Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-3811279d51aso7247093a91.1 for ; Mon, 03 Aug 2026 14:59:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785794380; x=1786399180; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=uVEhXqZ2S4ZB77O3YdEcMlIVSh8TdZgWM5WFDU+zGjc=; b=I4WxpEK+OvxkYGre5DvPosNir6eP7+MG0Ypv19POJ2i6M9YIlqGxlPH6QFn77vFBjq kf/i62Z5+ly7TaPtXogd2Ki9awJrWO0qhH+xjFkLjEZuiNu6PEkRZHjl5NlEw5Frhx3d yGIuihWZjahX5vgHXHwIxoEUWhC8Txm0Rmoh/V/un3nx6gRSwZHV9OuqAm9WIhHUGtwN x06DBGuM83WlM8dzUChOnNFzzcqb70LAJ+zRQPsGb69Hq6RI/o2Ead3yfjSnXgCKGekz 4/wdEWNBU9p0IUKu5okwKXnGd31ALxUR+nd/IPPWjFLfO7kINq9xd3+WlIGKp22adKVb 5Tvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785794380; x=1786399180; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=uVEhXqZ2S4ZB77O3YdEcMlIVSh8TdZgWM5WFDU+zGjc=; b=WvPvmGByZYnnKvpv+nqUEcZBzOHJF8KZ9xRyFwtpEGtk8iOHf9XLCq9dfsV3jLj509 WdmW/oHqwMpGszEJb/X2uOfRUkGwenVhe5gZRSfkljMwfT3NiSrGpejDZkdXnWyBvxWE xqxIN4V9vK7McuHCFK+f2hoB3Cn3CwclXw9vGLumgYFgnBGhuReACVytUbuEj8srlqP5 9/pW0LeM2+U/cZjDegLMM/Jxc61jchFmbo/tW1wipzpKiCDPSQ/E1bSEPvshcsFcD9yo IHxJZQsYoIePJf/fAgBsv/b+skB4LNQv5XMZnk8UgEpWHtUyCN73wYoG77sin58Vnedt b/Cw== X-Forwarded-Encrypted: i=1; AHgh+RrU3FbZeEWraoMgr+lmS5ms844EecjFvJw4y52yFw91f1GdT+k9nDmBwgt3ixHqU94hxdlgk3rWaBtfORo=@vger.kernel.org X-Gm-Message-State: AOJu0YwW+Ng7iCs/TVN1/7RL0BUHuv5lCRrvIkdRD9NICG/gOzGOR10o k49cbW//BsDqAlVmiScTiC6m2+i1i+evY4ofG7NWISkzWyQooqYpufVlhZYh69gQomdu3kqJwjP t7j1vLl+aWBV8niAST0My2bhS8eHpfCb4Xw== X-Received: from pgah3.prod.google.com ([2002:a05:6a02:4e83:b0:c9e:bb:ebaa]) (user=rathodpriyank job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:3392:b0:3c3:bbe6:95c7 with SMTP id adf61e73a8af0-3c92a59957dmr12749564637.17.1785794379417; Mon, 03 Aug 2026 14:59:39 -0700 (PDT) Date: Mon, 03 Aug 2026 21:59:37 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAEkPcWoC/z2NSw6CQBBEr2J6bROYjxldeQ/DYoAWOnyG9BAiI dzdkYXLV6l6tUMkYYrwuOwgtHLkMCVQ1wvUnZ9aQm4Sg8rVLXe5xsrgmz/oSXCkcSDfR7TK+KJ qLDnnIC1nodQ5ra8yccdxCbKdJ2vxS/++wmlndWa0MvaOCsUvXWhm4c1P/bMNoR0oq8MI5XEcX wx5i6muAAAA X-Change-Id: 20260803-b4-fix-aer-memleaks-524a1bd5e888 X-Mailer: b4 0.14.3 Message-ID: <20260803-b4-fix-aer-memleaks-v2-0-fd199b0171fd@google.com> Subject: [PATCH v2 0/2] PCI/AER: Fix ghes_estatus_pool memory leaks in error handling From: Priyank Rathod To: Mahesh J Salgaonkar , "Oliver O'Halloran" , Bjorn Helgaas Cc: linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Priyank Rathod Content-Type: text/plain; charset="utf-8" When firmware reports PCIe Advanced Error Reporting (AER) events via ACPI APEI GHES (ghes_handle_aer()), it allocates a snapshot buffer from ghes_estatus_pool to store the aer_capability_regs registers before enqueuing the error record into aer_recover_ring. If the error record cannot be enqueued or if the dequeued record cannot be processed, the pool memory allocated for aer_capability_regs must be released. Otherwise, unhandled errors silently leak memory in ghes_estatus_pool, eventually leading to pool exhaustion and breaking system-wide GHES hardware error reporting. This series fixes two memory leaks in PCIe AER error handling: Patch 1: Fixes a memory leak in aer_recover_queue() when kfifo_in_spinlocked() fails due to a buffer overflow (aer_recover_ring capacity of 16 full). The rejected entry is immediately freed via ghes_estatus_pool_region_free(). Patch 2: Fixes a memory leak in aer_recover_work_func() when a dequeued entry cannot be mapped to an active PCI device (pdev is NULL). Refactors the loop so ghes_estatus_pool_region_free() is called unconditionally for every dequeued item. Changes in v2: - Refactored aer_recover_work_func() to ensure ghes_estatus_pool_region_free() is called unconditionally for every dequeued item. - Added Patch 1 to fix related memory leak in aer_recover_queue() on kfifo buffer overflow. - Updated commit messages with detailed pool allocation and lifecycle explanations. Priyank Rathod (2): PCI/AER: Fix memory leak in aer_recover_queue() on kfifo buffer overflow PCI/AER: Fix memory leak in aer_recover_work_func() when pci_dev is missing drivers/pci/pcie/aer.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) Signed-off-by: Priyank Rathod --- Changes in v2: - Refactored aer_recover_work_func() to ensure ghes_estatus_pool_region_free() is called unconditionally for every dequeued record. - Added Patch 1 to fix related memory leak in aer_recover_queue() on kfifo buffer overflow. - Link to v1: https://lore.kernel.org/r/20260803183853.432459-2-rathodpriyank@google.com --- Priyank Rathod (2): PCI/AER: Fix memory leak in aer_recover_queue() on kfifo buffer overflow PCI/AER: Fix memory leak in aer_recover_work_func() when pci_dev is missing drivers/pci/pcie/aer.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) --- base-commit: 248951ddc14de84de3910f9b13f51491a8cd91df change-id: 20260803-b4-fix-aer-memleaks-524a1bd5e888 Best regards, -- Priyank Rathod