Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2811553rwb; Mon, 15 Aug 2022 11:49:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR70aU4Qc+FkzXvt9RaYLO7t84/UjXvAkcRRbs3C/Y3zr1H5TEXbS/4slZx4YLfE16Xq7T0j X-Received: by 2002:a05:6402:1907:b0:43d:e91d:e544 with SMTP id e7-20020a056402190700b0043de91de544mr15642991edz.107.1660589386896; Mon, 15 Aug 2022 11:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589386; cv=none; d=google.com; s=arc-20160816; b=CQwt/1Udv9tbGvMyOwwYhZ63XIveDKYQOUTdwrKs25wGbrYRtTBtmKQgMlEJgR+iPo GDJ78FMFlpfXhp5KT355nuJGiQa7BVrEvir2eVVuF+sg6ysJrU4DBumBGL7OktxnyC41 tBzJhk5NqyWfvTVQ48JJHGLBCWEFBjAUmxTl6g9CZ0kEKGmXdmAkQzV/JisylgHJLIPX /hs2w1MS+u84mSt9SqTiRkdcj3qti2ZqTmfqNjV1grWACmaiSvuBSvnpe8Y6ZOrhJ/eH 5Hwv9WsmgYI5ZeId83UmInV4eVC+Ow901CR5Re+7c/okfe3AeK131y6+aFvYJ9kpI7o7 mDCw== 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=iCtnGN0VrORiVK8vjrQy6KlHqLlxKOa1OvCojDPr/5U64I/ii6la5iEdkzpYblkzmi dG/bPPD8/gUdHzLCllkuuzmge2isLxNClzlum8vCMAcTwl7NL1EZ3Nr2LcT951UHLgmQ zmTzhxymXW8n1VcpU+RV7G0qpee0MxmOEpJzBtSeqXwXG9iJyzldJ/U7vDMkrKzxhPVl qxj5RG43aYgO1p+Oz24xkVM2R3135uMVFWW2yEy8yQBNY5VuSmMeFqJcvA8jwQnR6CJi ciybj/gygHQ0HO3rD+8e6kOiZ2Lr/uHJpW6/kMt5bUaG8dARUvSU5k6TdyMuEYL6um5G QtiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LzmJXVje; 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 qw22-20020a1709066a1600b007303cf80042si8750770ejc.697.2022.08.15.11.49.20; Mon, 15 Aug 2022 11:49:46 -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=LzmJXVje; 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 S243292AbiHOSd0 (ORCPT + 99 others); Mon, 15 Aug 2022 14:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243219AbiHOSc4 (ORCPT ); Mon, 15 Aug 2022 14:32:56 -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 71D2E33E37; Mon, 15 Aug 2022 11:21:40 -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 2ABAE60BE9; Mon, 15 Aug 2022 18:21:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05DC8C433C1; Mon, 15 Aug 2022 18:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587697; bh=r8VC5k8yCnxrmhJJjc40MMt9lv8g2qFUnZotxUDIYhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LzmJXVjeNWbCu0SuAShLhr9x248fRklJTVXiBlpa2sPplXjUPv7ljUVKRGyKPL9EK NLmG2EYBml2ilfgSjTZkIa9PVxlXJprkFPgoeaPP+Tm0rMX1a4jngBWwinfcmmUzp2 B0HJUmBKDasGTl1qEQ4tP4ow2JfelcK0iOnL4rXA= 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.15 167/779] x86/pmem: Fix platform-device leak in error path Date: Mon, 15 Aug 2022 19:56:51 +0200 Message-Id: <20220815180344.455772383@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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