[linux-next,v2,3/3] drivers/platform/x86/intel: fix a memory leak in intel_vsec_add_aux
Message ID | 20230309040107.534716-4-dzm91@hust.edu.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp94004wrd; Wed, 8 Mar 2023 20:41:42 -0800 (PST) X-Google-Smtp-Source: AK7set/8L9La7VY5M1opfxZ5AJiTWrp257VImqOSO88zw6cp7UtY/pUenE7hT8sYS9j28J5Jg4S9 X-Received: by 2002:a17:90b:3e8e:b0:236:99c4:6096 with SMTP id rj14-20020a17090b3e8e00b0023699c46096mr21068569pjb.35.1678336902351; Wed, 08 Mar 2023 20:41:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678336902; cv=none; d=google.com; s=arc-20160816; b=hdGa+UQA+XvifupIe3nsW+fC3hAL4WZRrwt2eoWBbXymXNU96kT/adqD0mtvFkqFFL 7BT1z8C1/cR7I0FZeg72PdKkXQpl1bjdT71VaETZPT/b0mi1GlGzAsoHjcXDVUGe5aq/ 4cFog9S3w/HsKoG5QCJ4bOf7UFbCMlDJbn7JttkSDeeQV9vPMhzCWi07pYeFRYM6TWn2 /auuJaLwGJeWAf5JDlBWcdW1wqBcMc04EbcSdNxrIuxVylxvsb2/Ac/3LAzIY2OP440f iYyW6XcP+89+iBne7sCaRrhWHAkwlw4GyTGidIMweTfGsPBJWPH2e8snHj6IkBjsYfJW uRCA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fjcRX6Iqeh2KFB4cCBQwLWAdXHFrQBcXhlcTGKQOAIc=; b=CwJpbijNvMiM6qzDBzdSAgiLAg0/i4c+uBzS5CW+W8ab7aT6xfnTT9dS4BCWblfQjC oH2wkVFlf3mCQ42GRAQGnHBqq8UvRlXfWi3uWCA8HIEWoOIIQXt2k16PwxkIrjoXfRUJ YLSRQ2uWfWLCKoFRw9nkK0V03D60WLmdNPfCCPgBGOmDeLOkssIjAQzFQAi3tsj/hDYD cdUfJ7lA2WkBsHwXrrmbHghmLsof/I7Q5qCzJBtQqBBpU7d7C2yCR6/OkgXbT9zVkqgF OMvFsPQHZbFvv4SV0XV/Cgm4s4rUPg5xPbCLtOkGfNH5iqgrtYBlDs0N9oudpKnvKveq 1wyg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i184-20020a6387c1000000b00502ea97a70csi15734782pge.837.2023.03.08.20.41.27; Wed, 08 Mar 2023 20:41:42 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbjCIEE0 (ORCPT <rfc822;carlos.wei.hk@gmail.com> + 99 others); Wed, 8 Mar 2023 23:04:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229954AbjCIEES (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 8 Mar 2023 23:04:18 -0500 Received: from hust.edu.cn (mail.hust.edu.cn [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF05769CD6 for <linux-kernel@vger.kernel.org>; Wed, 8 Mar 2023 20:04:16 -0800 (PST) Received: from localhost.localdomain ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 32943g7q028914-32943g7w028914 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 9 Mar 2023 12:03:57 +0800 From: Dongliang Mu <dzm91@hust.edu.cn> To: "David E. Box" <david.e.box@linux.intel.com>, Hans de Goede <hdegoede@redhat.com>, Mark Gross <markgross@kernel.org> Cc: Dongliang Mu <dzm91@hust.edu.cn>, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH linux-next v2 3/3] drivers/platform/x86/intel: fix a memory leak in intel_vsec_add_aux Date: Thu, 9 Mar 2023 12:01:07 +0800 Message-Id: <20230309040107.534716-4-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309040107.534716-1-dzm91@hust.edu.cn> References: <20230309040107.534716-1-dzm91@hust.edu.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: dzm91@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759863796036333200?= X-GMAIL-MSGID: =?utf-8?q?1759863796036333200?= |
Series |
[linux-next,v2,1/3] platform/x86/intel/tpmi: Fix double free in tpmi_create_device()
|
|
Commit Message
Dongliang Mu
March 9, 2023, 4:01 a.m. UTC
The first error handling code in intel_vsec_add_aux misses the deallocation of intel_vsec_dev->resource. Fix this by adding kfree(intel_vsec_dev->resource) in the error handling code. Reviewed-by: David E. Box <david.e.box@linux.intel.com> Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn> --- drivers/platform/x86/intel/vsec.c | 1 + 1 file changed, 1 insertion(+)
Comments
Hi, On 3/9/23 05:01, Dongliang Mu wrote: > The first error handling code in intel_vsec_add_aux misses the > deallocation of intel_vsec_dev->resource. > > Fix this by adding kfree(intel_vsec_dev->resource) in the error handling > code. > > Reviewed-by: David E. Box <david.e.box@linux.intel.com> > Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn> Thank you for your patch, I've applied this patch (as first patch in the series) to my review-hans branch: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while. Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window. Regards, Hans > --- > drivers/platform/x86/intel/vsec.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c > index 13decf36c6de..2311c16cb975 100644 > --- a/drivers/platform/x86/intel/vsec.c > +++ b/drivers/platform/x86/intel/vsec.c > @@ -154,6 +154,7 @@ int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent, > ret = ida_alloc(intel_vsec_dev->ida, GFP_KERNEL); > mutex_unlock(&vsec_ida_lock); > if (ret < 0) { > + kfree(intel_vsec_dev->resource); > kfree(intel_vsec_dev); > return ret; > }
diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c index 13decf36c6de..2311c16cb975 100644 --- a/drivers/platform/x86/intel/vsec.c +++ b/drivers/platform/x86/intel/vsec.c @@ -154,6 +154,7 @@ int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent, ret = ida_alloc(intel_vsec_dev->ida, GFP_KERNEL); mutex_unlock(&vsec_ida_lock); if (ret < 0) { + kfree(intel_vsec_dev->resource); kfree(intel_vsec_dev); return ret; }