Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp622168pxb; Tue, 5 Apr 2022 16:15:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi6TKpVH2FrLULfLHwbOsFGUl0rIFCxzL4v6Nh9TpknxW2khQC/afqxm8+1urrFHvcvmjx X-Received: by 2002:a17:903:2488:b0:153:8f59:8c03 with SMTP id p8-20020a170903248800b001538f598c03mr5931396plw.54.1649200537019; Tue, 05 Apr 2022 16:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649200537; cv=none; d=google.com; s=arc-20160816; b=YsKoI19wNSw8NEBTvd3ZGmlN7NTGbqCMJ+xWyg1ZGoPCWjz/C0kUelf8BhSQdmQUdw MdXXfIVXL6o5Yst6oAaHexgeTp9uwGoOBHMgHsV0KIUBALQtiXVHc8LqiGzhL2OZtgx6 alkIB8qMu+jJjmWNiUIsjDcUqbxFO4DQSeLUv+2I4iWdTBN5NSmMD8BsW9ecgUXo8vGU YIWiN2p2ACjrGoelRLNP8Y+ZOj3bXKXlxSUZYLA5nZt+ReTol2Mo8F/raYrd19Zvp4+S 2vtRNUPrjpl4OiSrV/dpKzZozHmoZkqM+HhggKZaDtlCVDQ7ZJ9WSYJPCng2Uy0AxHjo 1/Xg== 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=F4ts0J29OZlI5oriPppoq5JI/QDUpdYitn034tkRmNQ=; b=SSwcSj4gD+yub3txTvxLuNytdtSJnDIJVPL1etgMRoEBuuG1ulCKpIuKnV+Inz8fQJ jQf5pusJtqoO4DLeAyZngU5Eao15N21MToHLJTRkKD/JEGBAawopeKw0KuAOQC/Wp8sT f3NwKxYwLaiFANTNgHvm+chLXk50WgM3esNbODEn1xw8pxjhqTPieEXjTzLaA0M1atXu 0imdM/fql7FuCDDo/CDMoHWOD6+48Ab2pmiJl32UgOISEO4Atw64TomJ4WHa9aPZqUyf B+jbYeQiPqWANVIa2pzIXrIO5Yv3dKYnXDeI730NNPTA1s9ZcPYRaxpKmirdEV6o6VaH GRDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AakYe7Ya; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k68-20020a636f47000000b00382b76401ecsi16229946pgc.268.2022.04.05.16.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:15:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AakYe7Ya; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B267F220332; Tue, 5 Apr 2022 16:00:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347987AbiDELCP (ORCPT + 99 others); Tue, 5 Apr 2022 07:02:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236205AbiDEIlX (ORCPT ); Tue, 5 Apr 2022 04:41:23 -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 3846B1031; Tue, 5 Apr 2022 01:33:50 -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 DD837B81B13; Tue, 5 Apr 2022 08:33:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D820C385A2; Tue, 5 Apr 2022 08:33:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649147627; bh=lerBgQkdf9cnh0z/qLfVS+BV9J0u5dRvXHPnTlbTwuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AakYe7Ya+PquM95BUd17N6UFs0zkQblqm0HhpxxsRXxjX0HPKJaLrP/PnNaJscEAb q7F9g/KgC8y8TkjYXYyLqcNOXyD2mh9Q4TndHvqkoBq+xV1MgdGeh0Z2pma6CeIOle 0J2kFyyUj+23boVtJxH9p8R2hG32ZPeeY0uRfV1s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Javier Martinez Canillas , Johan Hovold Subject: [PATCH 5.16 0063/1017] firmware: sysfb: fix platform-device leak in error path Date: Tue, 5 Apr 2022 09:16:16 +0200 Message-Id: <20220405070356.056498410@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 commit 202c08914ba50dd324e42d5ad99535a89f242560 upstream. Make sure to free the platform device also in the unlikely event that registration fails. Fixes: 0589e8889dce ("drivers/firmware: Add missing platform_device_put() in sysfb_create_simplefb") Fixes: 8633ef82f101 ("drivers/firmware: consolidate EFI framebuffer setup for all arches") Cc: stable@vger.kernel.org # 5.14 Cc: Miaoqian Lin Cc: Javier Martinez Canillas Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20220303180519.3117-1-johan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/sysfb_simplefb.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) --- a/drivers/firmware/sysfb_simplefb.c +++ b/drivers/firmware/sysfb_simplefb.c @@ -113,16 +113,21 @@ __init int sysfb_create_simplefb(const s sysfb_apply_efi_quirks(pd); ret = platform_device_add_resources(pd, &res, 1); - if (ret) { - platform_device_put(pd); - return ret; - } + if (ret) + goto err_put_device; ret = platform_device_add_data(pd, mode, sizeof(*mode)); - if (ret) { - platform_device_put(pd); - return ret; - } + if (ret) + goto err_put_device; - return platform_device_add(pd); + ret = platform_device_add(pd); + if (ret) + goto err_put_device; + + return 0; + +err_put_device: + platform_device_put(pd); + + return ret; }