From mboxrd@z Thu Jan 1 00:00:00 1970 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 1A2F630FA4 for ; Wed, 20 Sep 2023 12:19:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 947B0C433C8; Wed, 20 Sep 2023 12:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695212374; bh=uT6+ofBvE7Bpufbp6Jy3HAPdXBXrlhAb5jZGMswd6ZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KjSgXaP/VpTfvI0yYr/tHVgz8LSXEqgP5GXOT4SiyaVXPGOBNzEMF9z7NbglDbACj cqgBeg5tAbaer5u/YJ1M6K/0u8IWqmQHfZ3bfwHXB4aTqaEoA2IkMijGmcCJkfqPgf kYrZMKyd03LxqGfTD1YfEmSCypWUyyj0dbSQzJmI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, ruanjinjie , Michael Ellerman , Sasha Levin Subject: [PATCH 4.19 253/273] powerpc/pseries: fix possible memory leak in ibmebus_bus_init() Date: Wed, 20 Sep 2023 13:31:33 +0200 Message-ID: <20230920112854.106526457@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112846.440597133@linuxfoundation.org> References: <20230920112846.440597133@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: ruanjinjie [ Upstream commit afda85b963c12947e298ad85d757e333aa40fd74 ] If device_register() returns error in ibmebus_bus_init(), name of kobject which is allocated in dev_set_name() called in device_add() is leaked. As comment of device_add() says, it should call put_device() to drop the reference count that was set in device_initialize() when it fails, so the name can be freed in kobject_cleanup(). Signed-off-by: ruanjinjie Signed-off-by: Michael Ellerman Link: https://msgid.link/20221110011929.3709774-1-ruanjinjie@huawei.com Signed-off-by: Sasha Levin --- arch/powerpc/platforms/pseries/ibmebus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c index c7c1140c13b6c..3fce7508a4fc6 100644 --- a/arch/powerpc/platforms/pseries/ibmebus.c +++ b/arch/powerpc/platforms/pseries/ibmebus.c @@ -452,6 +452,7 @@ static int __init ibmebus_bus_init(void) if (err) { printk(KERN_WARNING "%s: device_register returned %i\n", __func__, err); + put_device(&ibmebus_bus_device); bus_unregister(&ibmebus_bus_type); return err; -- 2.40.1