From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F09D8CE79D1 for ; Wed, 20 Sep 2023 11:49:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234650AbjITLtu (ORCPT ); Wed, 20 Sep 2023 07:49:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234692AbjITLtn (ORCPT ); Wed, 20 Sep 2023 07:49:43 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69166EC for ; Wed, 20 Sep 2023 04:49:33 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C385C433C7; Wed, 20 Sep 2023 11:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695210573; bh=KdSshYQlRWeRgh3VCUsyGbdwzwQTyTTYQXEMdZ1FC6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iVaJ+rZL+kVjz8hurbNVDCR04o7DxrGVaP+L1jTp1wVBt5R3qym+EjqyCDajmWNKB rc8bZPoJeAqMYR2mK2W5KdKdgAUrNhjrnWXk+Wq39YVEtIZdTr3T3VTbuehg+G1nck 0BDyFKVWxJ09+VYj/X147ZhyTlHUpSS3YTXWZ+cE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, ruanjinjie , Michael Ellerman , Sasha Levin Subject: [PATCH 6.5 101/211] powerpc/pseries: fix possible memory leak in ibmebus_bus_init() Date: Wed, 20 Sep 2023 13:29:05 +0200 Message-ID: <20230920112848.936347665@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112845.859868994@linuxfoundation.org> References: <20230920112845.859868994@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 6.5-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 44703f13985bf..969cb9fc960f8 100644 --- a/arch/powerpc/platforms/pseries/ibmebus.c +++ b/arch/powerpc/platforms/pseries/ibmebus.c @@ -460,6 +460,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