Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 370DD8249F for ; Mon, 19 May 2025 13:36:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747661811; cv=none; b=hc1RJaBZqkuuQve92heJt+zLzw6sqset70XrweX7Ln6tF3TOR6cadx19vyp3J9vME/4ks1+jU3lxNA0RLqeTumNQJNBu344b0bPVTHUoit/BcTFSQ+ST2O8bhM6mWeRePP14wPoqJrfs1Xqp1jB62pWEmrvhMGqpoxWxauZSk1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747661811; c=relaxed/simple; bh=vXtSSiYh8Uc+RFmkulNVdyLhVBR0G0IhSQYmlVWxsAY=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=jbCbGTC2uloR6LDKYP/rpf3Mq/s1uW+UvqkRQUyzAGnsiTIVXq02nMgDxRuQym5fPguP2kZHfDOZrDwjjp0+MaPlnsRusQGEn1FcWbAmscldcO6bPEtMZ6HUMfwopTduJPw/dGUQahugkeKGGxoVuf+VkNywWZY2ytaCDQfo0X0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DdJZC1D0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DdJZC1D0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2498DC4CEE9; Mon, 19 May 2025 13:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1747661810; bh=vXtSSiYh8Uc+RFmkulNVdyLhVBR0G0IhSQYmlVWxsAY=; h=Subject:To:Cc:From:Date:From; b=DdJZC1D01vPLtQudVUq8ulnxBoT5mPXU5qydWe3UqzYH9+ShE0e0PpKCxjufY5rKB syYfPzDRU6J18Vt6j2GRcCJAFzGNLrpgTSoL8BnbHkPRaf2R+MF2F5J1MFFeLOWhsZ xnMbcBaW1GELl0eSiNYRx/M7LdIOPlcadW00A7+M= Subject: FAILED: patch "[PATCH] dmaengine: idxd: fix memory leak in error handling path of" failed to apply to 5.15-stable tree To: xueshuai@linux.alibaba.com,dave.jiang@intel.com,fenghuay@nvidia.com,vkoul@kernel.org Cc: From: Date: Mon, 19 May 2025 15:36:47 +0200 Message-ID: <2025051947-vexingly-upheaval-8642@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.15-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y git checkout FETCH_HEAD git cherry-pick -x 90022b3a6981ec234902be5dbf0f983a12c759fc # git commit -s git send-email --to '' --in-reply-to '2025051947-vexingly-upheaval-8642@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ From 90022b3a6981ec234902be5dbf0f983a12c759fc Mon Sep 17 00:00:00 2001 From: Shuai Xue Date: Fri, 4 Apr 2025 20:02:15 +0800 Subject: [PATCH] dmaengine: idxd: fix memory leak in error handling path of idxd_pci_probe Memory allocated for idxd is not freed if an error occurs during idxd_pci_probe(). To fix it, free the allocated memory in the reverse order of allocation before exiting the function in case of an error. Fixes: bfe1d56091c1 ("dmaengine: idxd: Init and probe for Intel data accelerators") Cc: stable@vger.kernel.org Signed-off-by: Shuai Xue Reviewed-by: Dave Jiang Reviewed-by: Fenghua Yu Link: https://lore.kernel.org/r/20250404120217.48772-8-xueshuai@linux.alibaba.com Signed-off-by: Vinod Koul diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c index 302d8983ed8c..f2b5b17538c0 100644 --- a/drivers/dma/idxd/init.c +++ b/drivers/dma/idxd/init.c @@ -587,6 +587,17 @@ static void idxd_read_caps(struct idxd_device *idxd) idxd->hw.iaa_cap.bits = ioread64(idxd->reg_base + IDXD_IAACAP_OFFSET); } +static void idxd_free(struct idxd_device *idxd) +{ + if (!idxd) + return; + + put_device(idxd_confdev(idxd)); + bitmap_free(idxd->opcap_bmap); + ida_free(&idxd_ida, idxd->id); + kfree(idxd); +} + static struct idxd_device *idxd_alloc(struct pci_dev *pdev, struct idxd_driver_data *data) { struct device *dev = &pdev->dev; @@ -1255,7 +1266,7 @@ int idxd_pci_probe_alloc(struct idxd_device *idxd, struct pci_dev *pdev, err: pci_iounmap(pdev, idxd->reg_base); err_iomap: - put_device(idxd_confdev(idxd)); + idxd_free(idxd); err_idxd_alloc: pci_disable_device(pdev); return rc;