Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2653427pxa; Mon, 17 Aug 2020 15:36:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz18DkERRzgUJ2/5wNgqbG1nh2eQhZbkx4uvYVc9YZ0gXiT3AjOxzybrhQt5TnEhz7KD3Yp X-Received: by 2002:a17:906:95cb:: with SMTP id n11mr16673904ejy.506.1597703761671; Mon, 17 Aug 2020 15:36:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597703761; cv=none; d=google.com; s=arc-20160816; b=rHaiRuLGRckCDkLVh56JJitgOYOZZnavAomOHeBthahHN3PUBG91Mb1DDsNYmkza5T 22ndvRTDpXA1rRt6OSlRERZRjhdUsyn/SCadbQ/sDWC2n1Av8FlyeoO1NP5EO7yTBpUO l1gv0sSaLIJWMBKsgLfsHySSQ/d3Xxnl8ur57TltVzeok0wKHr/0NxKfJdD7K6sjhkBI uowDRZb6meonB/HwtBOt0NNCAEcmeFDNFOC1b9Yp41H4SFlUG+OS0JqNhumpQOj08omG qsdKoINSDVPNPmQvKOCkfJl5mGvBnXU0wCMKh9jyWL232S5QGBmad+wNrLS3M8KiZXjl k2Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=v0QYRDUOrpPzjcG885dHPTREbXUaIug8wzfr0j6wlHY=; b=gt0/+eOmAGyK/fhbii3y9y+dcjv/OOFv4DP0segVxsELsd75Mmw4ZHjmdBAG53QdUk +kuAleeKtkMnghA7ANDq0IcScBUKtYH3hf3VcoCpXlQxPkwjfMWOOZ9EN5uUo+PVCCaH p8w3Hz9em5aHhXSjhghilL2Xs0uZqSR9QENVARGHmU9L3d+YcF/VjPs+splV4pJkCj9N x8N6lvwA4/w1U8ycakc7f+vDSukzXPgrgGYmbwvzLszurJpsqPpseeDYnHzpIoMYSKZF 6jTbFVoKmZnB8Ylxw04wmM9z10AVylnez+MZt2R0vuPRFxY4q5BuuilqTwOy84smM7lJ 2ytA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PHOI44LS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x13si11975953edv.323.2020.08.17.15.35.38; Mon, 17 Aug 2020 15:36:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PHOI44LS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389410AbgHQRKw (ORCPT + 99 others); Mon, 17 Aug 2020 13:10:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:39198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388604AbgHQQLO (ORCPT ); Mon, 17 Aug 2020 12:11:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C1B7820658; Mon, 17 Aug 2020 16:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680671; bh=U+gWfkrY3BsVuOe18g1jlpr8DJgrJunvSINNKdy/Hcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHOI44LScfXG7iNATNIqy5Pmoy6eFxcA6EmPkjnqnovHfrp6pT2zZmzl4t1w7y5AI urqdzdiw2JyGIOzq6SzNtrMuSqozA9OzHVP5Nn3lD+f+i67Mr9cGQNH98b+UGfR/ri SDEis6NFEHLuGKhygMm9/YjT8CNXlT0FlvJzVKBg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qiushi Wu , Borislav Petkov , Sasha Levin Subject: [PATCH 4.19 010/168] EDAC: Fix reference count leaks Date: Mon, 17 Aug 2020 17:15:41 +0200 Message-Id: <20200817143734.228179359@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143733.692105228@linuxfoundation.org> References: <20200817143733.692105228@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qiushi Wu [ Upstream commit 17ed808ad243192fb923e4e653c1338d3ba06207 ] When kobject_init_and_add() returns an error, it should be handled because kobject_init_and_add() takes a reference even when it fails. If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object. Therefore, replace calling kfree() and call kobject_put() and add a missing kobject_put() in the edac_device_register_sysfs_main_kobj() error path. [ bp: Massage and merge into a single patch. ] Fixes: b2ed215a3338 ("Kobject: change drivers/edac to use kobject_init_and_add") Signed-off-by: Qiushi Wu Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20200528202238.18078-1-wu000273@umn.edu Link: https://lkml.kernel.org/r/20200528203526.20908-1-wu000273@umn.edu Signed-off-by: Sasha Levin --- drivers/edac/edac_device_sysfs.c | 1 + drivers/edac/edac_pci_sysfs.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c index 0e7ea3591b781..5e75937537997 100644 --- a/drivers/edac/edac_device_sysfs.c +++ b/drivers/edac/edac_device_sysfs.c @@ -275,6 +275,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) /* Error exit stack */ err_kobj_reg: + kobject_put(&edac_dev->kobj); module_put(edac_dev->owner); err_out: diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c index 72c9eb9fdffbe..53042af7262e2 100644 --- a/drivers/edac/edac_pci_sysfs.c +++ b/drivers/edac/edac_pci_sysfs.c @@ -386,7 +386,7 @@ static int edac_pci_main_kobj_setup(void) /* Error unwind statck */ kobject_init_and_add_fail: - kfree(edac_pci_top_main_kobj); + kobject_put(edac_pci_top_main_kobj); kzalloc_fail: module_put(THIS_MODULE); -- 2.25.1