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 2F28FEEB57A for ; Sat, 9 Sep 2023 00:27:37 +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=Fo/wIke2; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RjDMW1kzpz3dSm for ; Sat, 9 Sep 2023 10:27:35 +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=Fo/wIke2; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=139.178.84.217; helo=dfw.source.kernel.org; envelope-from=sashal@kernel.org; receiver=lists.ozlabs.org) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (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 4RjDJV5QsNz3dFh for ; Sat, 9 Sep 2023 10:24:58 +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 dfw.source.kernel.org (Postfix) with ESMTPS id E59C861222; Sat, 9 Sep 2023 00:24:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D56A0C116AE; Sat, 9 Sep 2023 00:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694219096; bh=PICMPaRjGCXsc3BwAw/ZgNkUaNI4qSHadrZ+ejRG5Go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fo/wIke2ku7AKODUL4vL0rT4pNwNg8S84ZdA9bs8xnNw6s8VsfPsBcMvmdqcpDPAL y1Aa97YpvIbwUPCDqJTChH5ipzGV3Wd2ESF0v49K141w7vFlRz3I8lJPmr3nwcXAAW cCBOPT61yConPXFhhI9XMIGx8A0xo6k4j0e/vJranGnkxTvUgaDsfhE7CBrHI2InYQ ydTUaayQuHar4e9PA8R1e+gGYmvc8jFSkZ6icbC/QTI0rJFf/3hloNmqEClZwMcKU9 xzjhmQmpxABKcSj3bGE030zWQYqaI3OxFhh3K+2YG21CcIP5Z392WMv0jXuFy2axeG +BQcrgAtkyNhw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 5/5] powerpc/pseries: fix possible memory leak in ibmebus_bus_init() Date: Fri, 8 Sep 2023 20:24:40 -0400 Message-Id: <20230909002442.3578957-5-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230909002442.3578957-1-sashal@kernel.org> References: <20230909002442.3578957-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 4.14.325 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, wei.liu@kernel.org, iwona.winiarska@intel.com, ruanjinjie , gregkh@linuxfoundation.org, sfr@canb.auug.org.au, linuxppc-dev@lists.ozlabs.org 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 408a860441330..a3d6d064754e8 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