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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F329EEB565 for ; Sat, 9 Sep 2023 00:24:14 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=DF7qo/Ge; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RjDHc2pJ9z3cKc for ; Sat, 9 Sep 2023 10:24:12 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=DF7qo/Ge; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=145.40.73.55; helo=sin.source.kernel.org; envelope-from=sashal@kernel.org; receiver=lists.ozlabs.org) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RjDGC5zWcz3cD5 for ; Sat, 9 Sep 2023 10:22:59 +1000 (AEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 8EBD8CE18B0; Sat, 9 Sep 2023 00:22:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99F4BC43397; Sat, 9 Sep 2023 00:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694218976; bh=U8SVG3ed5aOkz47y6WQTq3badBZrFa7OwxFB5JFpvMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DF7qo/GeJkK3gmm8xlP8FptT52i5ymd9r0dxseoear5+0KTuBpAftQdcm4ppPM4bP 8oSu2YuDdAUs9LMKdvZg7ne9aaCWrFsfbiZvUlFavwhU2RoUFHX8M8t3UgTRwvMpf5 M2nTQEiIsxoTkt4PvnWUr7WtSrj9z/3/+D8z+lPSrF2wYs8wXTkuirg5P+X/Xv/nog XFx3P4rLCSBohwBZYf+LYSvoK9iW4PliJIfoq3Tsxsj83EHnXLIkhIcVa7aRY/xegb m2SLYIWM9HFHnz99tyUeVUqD4Ei+9aREeKIrg/XN0Kg/Fw3Yy+2e3auYGHXrzwUDJV sBksktGeMzRlA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 6.4 09/11] powerpc/pseries: fix possible memory leak in ibmebus_bus_init() Date: Fri, 8 Sep 2023 20:22:29 -0400 Message-Id: <20230909002233.3578213-9-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230909002233.3578213-1-sashal@kernel.org> References: <20230909002233.3578213-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.4.15 Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , robh@kernel.org, sfr@canb.auug.org.au, ruanjinjie , gregkh@linuxfoundation.org, idryomov@gmail.com, linuxppc-dev@lists.ozlabs.org, dan.j.williams@intel.com Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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