Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3415197rwa; Tue, 23 Aug 2022 04:31:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR40YeHhwbyTA4CbJRfr342EurYmPVYogK32svbe3pTLpj/MnpRRzjaia35RYnP21zBlM5tL X-Received: by 2002:a17:906:93f0:b0:73d:8f14:1e4a with SMTP id yl16-20020a17090693f000b0073d8f141e4amr4163479ejb.235.1661254185335; Tue, 23 Aug 2022 04:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254185; cv=none; d=google.com; s=arc-20160816; b=jDu8Zo6wCRPHuwvpIBytdZ4TC3eDiXuL2Wa69lL+viauptWoRRqH/qFyhoWyG60M3B feEpc3u1FTO7YwCZH8qswJJuEEeSBRHCQtBPQXC08a2OrDvFhWD58ABDvKfWROpuFwdl S9/NsADhtfBxhT2dxUKS9x3vObLBW4padeRI1Zk3fl9KOa+dH9IXwJpuvpTyz/GWSRLH EQ3bR72wi/mxUhV8qbnf7vHha4jWrSApa2J+DE/4J1M1A1wxMi99Rexo5v8AkAWb0e65 a7gJz9bj4o7cVsmgjcsa73v+cxairyDTOXcUzhzTDMwSqMO6sPUG9zCywzUlwpw886An QVhA== 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=s8Sbcn/ZzEwm7A1lP5363BbluQSUc/MkY69KDpi0bHL3rquK2062Cv1v2cJZtroTNW bcqOvORr6HPDlwztZsFVqPySFM5/tP6u/F2+zrBxfYN1to6Qut8rE2ksYCKk2xXBHLlS yIWCFD9AOYth0AOUF7SxhXp5x1T2zFXfFEj4wwql2zSInxl3NB+i4+6/5bRwCeMzCqnZ UMz5rd3uk0J6eZhPJZJXWzzKtw6niq7lO2YSzdi6lt2T5hsth83RWwuPBa5BwhKAe/KN YA5lzxAw9jQTtqVNes/fYjPQWRw2hNdyayl+87aLoqXtnwWRr++kBFQ1MiVu0nrwKt6W xKHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NX9+ek1s; 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 j6-20020a05640211c600b00446db5e5769si2377378edw.346.2022.08.23.04.29.20; Tue, 23 Aug 2022 04:29:45 -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=NX9+ek1s; 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 S1355480AbiHWKgR (ORCPT + 99 others); Tue, 23 Aug 2022 06:36:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354424AbiHWKVZ (ORCPT ); Tue, 23 Aug 2022 06:21:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77E2D81B23; Tue, 23 Aug 2022 02:02:48 -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 DAC706156F; Tue, 23 Aug 2022 09:02:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D574AC433C1; Tue, 23 Aug 2022 09:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245367; bh=r8VC5k8yCnxrmhJJjc40MMt9lv8g2qFUnZotxUDIYhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NX9+ek1sxh5NDRpp5j843cfP1Ol3PgWgv1Ur5ZQ7nPyz/KFxe1GO7LRjrUhrTXdnu 10W87Y9AUH+KOMQdV2iAraZCCjg00aBf3fQQHYFd1LLtfLmBG4GsMdfPTLhbbT+BhW YJqtrJ4KAnvO2nCGgrL9KZL8YRKIKqoqzqMDOpsE= 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 4.19 056/287] x86/pmem: Fix platform-device leak in error path Date: Tue, 23 Aug 2022 10:23:45 +0200 Message-Id: <20220823080102.133716652@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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