From patchwork Tue Dec 20 04:59:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaoqian Lin X-Patchwork-Id: 34904 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2788191wrn; Mon, 19 Dec 2022 21:43:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf41xiPvrs5vrfDYiWLGonOwBGy1m8JjF9rVEAhloJ0btK5b4cLdbhzLqyKDFhlnHzZO9UXJ X-Received: by 2002:a17:902:cf03:b0:186:8568:be7e with SMTP id i3-20020a170902cf0300b001868568be7emr57505733plg.15.1671515020122; Mon, 19 Dec 2022 21:43:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671515020; cv=none; d=google.com; s=arc-20160816; b=TkJjcZNgDDKtqZiOlVfrjSEHlusr/SSRi4ZaYC5bos4eTwiVXI/FGPae0TvPyWGyYa o6mOgmlI5jmOHhXx9qi/a4lWqy5xLKTXFTxz8WPri3tkYoSRF6Co5UFHoxvO/oGJmQ9K Q/BBqjO7EVS1V64Mh8elRAfSx/50KCcQHnc6wBGt5qcTefF9na1BtrmTAMSjpahBNh2b /YZ21OxWDJF7d3ADReOJbymd9BJiKIGGbZgnd09pP5G4ZiJI1geaGBgNM/NbkA5YIQZQ ZtXOK+QIcHYk17HyYWxRiHcUDVxLxpSfeF291k/Y1llap5Yjy/NxWMUrd+RYIwi5leBr u8tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=6MBdNuzRmYZGPUVsUdzTX10W9MvR0khMZxSOxixUkqw=; b=exQhQwclxKYMHoMn1RxjAEs4D/q8knwqDJgANp3mGfqE8FcDs90hRKgXO4AkMlABPD zGVjbmGTDR6RgyUhiyYKCGR4PLG70RukFr+1p/UvrhhJqxeonX8qCMfapczUCHixCMYj XfG0kmKiKcoCWH8+fLcomBtHD+k5ZtVbg5jcHK1PvaqWH4tD3/31lqB9bG/waLJ9P2ct FaSEG1Vr6cmiLyb5dJufZGG51eOWFa3uQe4lgGmevtyLaH5sGE+Uh135lTSicHEr54MI UCKNAvoZY+4/Zc+sTpR4CrR4NG+iPt0aEOkae/TBrpYkGzAl1HRHB248rFOPrzLvlKUn hreQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="HNs/gmhK"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a5-20020a170903100500b001910f9d150dsi8372095plb.335.2022.12.19.21.43.27; Mon, 19 Dec 2022 21:43:40 -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=@gmail.com header.s=20210112 header.b="HNs/gmhK"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232967AbiLTE7o (ORCPT + 99 others); Mon, 19 Dec 2022 23:59:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232394AbiLTE7m (ORCPT ); Mon, 19 Dec 2022 23:59:42 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42D9A10FF3; Mon, 19 Dec 2022 20:59:41 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id x2so11098068plb.13; Mon, 19 Dec 2022 20:59:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6MBdNuzRmYZGPUVsUdzTX10W9MvR0khMZxSOxixUkqw=; b=HNs/gmhK/nROiKYidMSIQkGMFrSYg/8+JDCCOulLFewzX3/GPHvWSSTudmdnj45py7 Ouy+wbnzJ06kK8gAyYChDRLnEgA0xH1W2ATvPxu79Lgxuofc6VIF5KbGLe9fILTS5Gj0 QiHmEIfzxCvMEZrLKwS7PByaVAg8oCUCRbl2Mu7x/7zLtpTkQQw98f/1C8KTvN2fMo1B oTMFqDTExAonnCmdE3dprWCT/XJkFIN/k2+vIlEmSZPuqMdjywskHMB+z/s1TE2xDaEa NkzDvyIjCt55As3YP51lO9VeiZH4Xm/6QP8AKMdBo3GDrKFGkIBO0h3yNEFyiowFuv37 oQTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6MBdNuzRmYZGPUVsUdzTX10W9MvR0khMZxSOxixUkqw=; b=NPbs25V47cizg9bE18WnhuTjwVJlO3OWae6PRbuMvZV9FmRd2CFDsdvcXiEcrJUzrj UXXlLjgUX+MgevQM+cBdeh4t7zLYByKL2/3Z8vECD/Lx88aA1/OtT995qfUIRXjBgdih Dyjr5OgTiyWlUnfvLciGcygJbMvbxWaLtBvHVxoM//MCNMRJS+VOkd3vWuNnZBVAiwic cN21jG5ePqdxi2nVR1ivgGnjKAbmX+NkKIJKcnjrr7aJEUj04Kr3OU8+VGbww7ln2Tz1 0QCwM9GScEsSkjpAlmbIyL3wUi3r2qZxj+uNwHFbV+rIeqcLovEJ2AE4EcDWp3nOao3z V8xA== X-Gm-Message-State: ANoB5pmqNjA8qMblf7NO/aJJBl2LiyPaxFVDtVc4+gw2AYfazt01U8hZ 0LYM8aJeh/M1iPdu3qJwWYE= X-Received: by 2002:a17:90b:fce:b0:219:3ad8:9190 with SMTP id gd14-20020a17090b0fce00b002193ad89190mr45881560pjb.23.1671512380743; Mon, 19 Dec 2022 20:59:40 -0800 (PST) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id 7-20020a631347000000b0047063eb4098sm7137784pgt.37.2022.12.19.20.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 20:59:40 -0800 (PST) From: Miaoqian Lin To: Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Bjorn Helgaas , Yoshihiro Shimoda , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linmq006@gmail.com Subject: [PATCH] PCI: endpoint: Fix potential double free in __pci_epc_create Date: Tue, 20 Dec 2022 08:59:29 +0400 Message-Id: <20221220045930.1106921-1-linmq006@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752710533703203827?= X-GMAIL-MSGID: =?utf-8?q?1752710533703203827?= When all references are dropped, callback function pci_epc_release() for put_device() already call kfree(epc) to release memory. Remove abundant kfree to fix double free. Fixes: 7711cbb4862a ("PCI: endpoint: Fix WARN() when an endpoint driver is removed") Signed-off-by: Miaoqian Lin Reviewed-by: Manivannan Sadhasivam --- drivers/pci/endpoint/pci-epc-core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 2542196e8c3d..7dc640c99d9a 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -800,8 +800,6 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops, put_dev: put_device(&epc->dev); - kfree(epc); - err_ret: return ERR_PTR(ret); }