Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3029010rwb; Mon, 15 Aug 2022 16:27:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR5xTveXiBs9R6dUY32uTFgPvEFVDH4Hx6HlZhKIp++yFZPRC65zd6PU0ITI/IQbvjbavgH+ X-Received: by 2002:a05:6402:501d:b0:443:1c7:ccb9 with SMTP id p29-20020a056402501d00b0044301c7ccb9mr16372648eda.101.1660605961689; Mon, 15 Aug 2022 16:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605961; cv=none; d=google.com; s=arc-20160816; b=BSDmweC5crCZzPnUm7ghb/2rG8N9HoUJORsW8u+JmA9x5+xqjaMObhcpggHIowihDw ctXT1pqluIW6Vj+gOwEhvp7cA4cX5sN6XNqcdsJLbNDUfkyrEhmZK+5YZlHKquH2fhAY 2KP9rtFhoZ5D/vtVKxy+zLv5XaAPBx+hHpohCpb/40kNNyiKZie6CTTTqnX8c1MJORH7 ocP+m88k5Q/CJX5FG3z1SK2zJOIXo84P6eLqFENaEcLiJmY4BAsq9eDM1NMsYALa3QlM w7QqjN5Blg15j+UifHS29KxweW78XtCCB4Fdm+3rglqj8dbuREsVCA7T6+cXWAAID9ne XQGg== 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=yzSjC16Shdm0pJB69fQCLGN8/VfKN0AHJbEZ/fgqxtF6ww6nnWXtxtU3OScuGma7J7 AaHL6+xU7pvLzF9BLq90YqiaK/qphE7iVP0REPlw4rVCLV6ZELvOOFvpGDZKW6KdVrts fJyHLMU1pX212Oo8MT3HdhXzyLfWCR3I3BmSylo8rRnpXZDQ2+TgJ7mYV8D1f83ZQTB1 9eyZgnCp0rZEHNWmgqXrWHKWqBByZqHFCCAnRuTIBfRvpG/n8byWSkQFc5bCLI9eSTmn BEyqCLSB8KY4mjxfKVHd53joVl6il0fQ/ltulgsNAdZFWACl6KSOjakAGfw7R8nTPxI4 0z2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yBn1GruB; 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 u23-20020a1709067d1700b007308f39b5afsi8232201ejo.407.2022.08.15.16.25.36; Mon, 15 Aug 2022 16:26:01 -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=yBn1GruB; 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 S1352274AbiHOWze (ORCPT + 99 others); Mon, 15 Aug 2022 18:55:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352267AbiHOWyE (ORCPT ); Mon, 15 Aug 2022 18:54:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5488F139DA2; Mon, 15 Aug 2022 12:54:54 -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 ams.source.kernel.org (Postfix) with ESMTPS id AAAB9B80EAB; Mon, 15 Aug 2022 19:54:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF34CC433C1; Mon, 15 Aug 2022 19:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593291; bh=r8VC5k8yCnxrmhJJjc40MMt9lv8g2qFUnZotxUDIYhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yBn1GruBmbMCRmBJyIvswCvWFV05XoFrVJ8saWFSda8JIn6YkEcwWaF8NfffRaN5S 2uO7n+kCOqax+yWpJC50P1mVyXueDqwNiBs+IhIfgbnAp2TOM88yq8o2NCa9LoXt3o VP4GAIQh59xamio3uNjwF9V9VrTJhUB0KoFsKDKA= 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.19 0213/1157] x86/pmem: Fix platform-device leak in error path Date: Mon, 15 Aug 2022 19:52:49 +0200 Message-Id: <20220815180448.135034713@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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