Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2928154rwb; Mon, 15 Aug 2022 14:13:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR6jYfPDoDKAaPuccVbkLd0LqoyUXjB1H8aRszUA1z2/i0Qmcn9OwieTKQXU2uIoEXxZsP6k X-Received: by 2002:a17:907:7f11:b0:730:6f6f:e444 with SMTP id qf17-20020a1709077f1100b007306f6fe444mr11117887ejc.657.1660598021797; Mon, 15 Aug 2022 14:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598021; cv=none; d=google.com; s=arc-20160816; b=A7l09voIpLjrOUPuZcu187LYN/ekUj1P8wUdJWh4rKMT8X3lEXMw27ETezYRYbyAIl BX/B2zvSgcAba0fo26H4ABXRuVs7/OUZ+/A16tEVh6WZOhFEbp6c6zsqeYS03LloKyNS 7lZ+BxV0FIjEIMxGFAC5TIZbs4QIZQ5u6A00Huy8Cl4f2WTaqoNYYxHVZgnSFuwt8x43 2D0s9qAsnOLd7sw5m4j6JsW2mWuFrNTxNbKtYEl8q2NdIvFgvyddT1zWr/vie3EDLw7U wY23pUSphG2ALs8iUSkte8UKjJBu8txBo0x29+3AfwRdX0OWOZw8zfyZcBTeq1VyPBnf MNeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m2gcVdckvB1yXj8Za1IzK2PptZTTodhItGl6SFJzyf0=; b=UbcPkM+0CDQMKdulZWzOmXR8juXsReRz9fHgwdJ9rlrWwnKLCSCVMJlcSSZHoFp0nY DpdE3f0/FxVCG/Waa3XDIuXFdAnAFY2IIjohB5Pg+jDRKnHSNZvZNmL0KakBiqDv4vVM wybQ9TksCV7+eGdVoBRdJ6n/5+d+DkPnACfaxpJV27RPPyc1++CO3VbGDDm4lmVDBmQY k1zSGji/VgbYWxwU6f+tfno+ohpvhhpu6oRVOJekB5VfYq4m1Okd6sDUVMJ+I77rxcYk F5kWnZbieNjIV/LbvWwUykAiexyvjTikflH51J4xDom9HhihDoHf5CEN1zU2L3c8OjO2 wieQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s1m133Y9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bo20-20020a0564020b3400b004434a6df06bsi6863117edb.310.2022.08.15.14.13.16; Mon, 15 Aug 2022 14:13:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s1m133Y9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245221AbiHOUiC (ORCPT + 99 others); Mon, 15 Aug 2022 16:38:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348296AbiHOUc1 (ORCPT ); Mon, 15 Aug 2022 16:32:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACA4913F0F; Mon, 15 Aug 2022 12:05:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D2AB761299; Mon, 15 Aug 2022 19:05:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8C2BC433D6; Mon, 15 Aug 2022 19:05:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590329; bh=r8VC5k8yCnxrmhJJjc40MMt9lv8g2qFUnZotxUDIYhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s1m133Y9WgbzeidEUh86d8sbISjNrpGMyVczHLC+t5HHnI+bsB1MrwrtM0Ke5UxcU tnpIczr2dXquMMgoKYvkUHi3wDKxx1kg8v8A85Ccf6A8/QlxfwWdtJKJqo2JkEZ0bN u2InamQ1cCiteE8H9kJ91nWjPJPlpua9+3NQhgJE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Borislav Petkov , Sasha Levin Subject: [PATCH 5.18 0198/1095] x86/pmem: Fix platform-device leak in error path Date: Mon, 15 Aug 2022 19:53:17 +0200 Message-Id: <20220815180437.818621157@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold [ Upstream commit 229e73d46994f15314f58b2d39bf952111d89193 ] Make sure to free the platform device in the unlikely event that registration fails. Fixes: 7a67832c7e44 ("libnvdimm, e820: make CONFIG_X86_PMEM_LEGACY a tristate option") Signed-off-by: Johan Hovold Signed-off-by: Borislav Petkov Link: https://lore.kernel.org/r/20220620140723.9810-1-johan@kernel.org Signed-off-by: Sasha Levin --- arch/x86/kernel/pmem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/pmem.c b/arch/x86/kernel/pmem.c index 6b07faaa1579..23154d24b117 100644 --- a/arch/x86/kernel/pmem.c +++ b/arch/x86/kernel/pmem.c @@ -27,6 +27,11 @@ static __init int register_e820_pmem(void) * simply here to trigger the module to load on demand. */ pdev = platform_device_alloc("e820_pmem", -1); - return platform_device_add(pdev); + + rc = platform_device_add(pdev); + if (rc) + platform_device_put(pdev); + + return rc; } device_initcall(register_e820_pmem); -- 2.35.1