Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2927558rwb; Mon, 15 Aug 2022 14:13:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR7BEMv/uNtMp+eEYTtVaD7GUoVOyARdZcQvF7/X8ujDNFGVDxItvT6fPKgdezxTjH0Faimu X-Received: by 2002:a05:6402:2387:b0:43d:3e0:4daf with SMTP id j7-20020a056402238700b0043d03e04dafmr16110475eda.208.1660597981486; Mon, 15 Aug 2022 14:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597981; cv=none; d=google.com; s=arc-20160816; b=lxTGydaTWU1JWz4w7P5qHrCeXLDiLh0HXbGl+OGFxJe2Dw87ZPTDDlQPW1I7XlMP/3 gLBJDr/KWGZQZDHaHm9tJL3mcONfKpM0K3rU7F0LUH4rMwDSV20pAMSnw1aabyTo56B7 5neJhsieooYkUiuqUc+n5EHVt2cOpkXb2SYc1YkkwSZnM7YfUvmKfTaF/y1XQEQTWSSg qBxAstTnMKSfaqjjpB4lQB946L5qQvJ2CW0BjmHepi01wGYBN4gBxlS2E9h5yondXk3c TR4xAtA1jtCWpQ7MgbS37dVAbwKw7WZ7M8hNmIaMhvUyUomWdLAudgbKRezrgSVpVGrX 24QA== 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=ws/L5Zb5DMCyU8LqvK8B3PiUWJQX4Ce5o8uwjXIE0Qg=; b=YoIQi5M7Efc2sTIIqbflqcRPn5QYkRLXNhsDb8wiSfkbaQWhrYovFEa8nJRcWIG2DS vHOBV6kjoMAM15dByv+/EOAKoXDuFr7wUT7lCcZN0HTh7W7HyOjZKw09HaGtYQHqP8ko +dkiASg03TRfA0u+LZgylDoZSGAE/EQ9UT9KU7y9J0kyU1jZnGZ8OhBk8t7DzKdajWoe LKEv6NCXhGeQdb5PGE2U0CA0vDdw4Lmk7Rnu3EBXGoUI85AHIUeE65iQERoXQYGxcvi5 Z/Jm7yxq6u2oiXTFs57g+q5eJpOpfo+uIapPO0XsXgv2E/OYc7IfByPTk5JAtDNgea8l Y2fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zmks4f3f; 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 z9-20020aa7d409000000b00440367fe313si7339237edq.305.2022.08.15.14.12.34; Mon, 15 Aug 2022 14:13: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=zmks4f3f; 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 S1346347AbiHOUlZ (ORCPT + 99 others); Mon, 15 Aug 2022 16:41:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346098AbiHOUff (ORCPT ); Mon, 15 Aug 2022 16:35:35 -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 E47DE2AE3A; Mon, 15 Aug 2022 12:06:43 -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 822E661019; Mon, 15 Aug 2022 19:06:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F1A4C433D6; Mon, 15 Aug 2022 19:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590402; bh=mxljtDHMst5iwqEorc0AT/oDFsf1xLqdqqSlxIcDaPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zmks4f3fQmOMKXXz5MFXoAmKtXVIFKpn4cQhrs8ygKeZQMY2RGEOZnmN1rbveBpIX x9AavJWf7uR091NJcTiNh1uWdClO2ZJuMtOzp2NcFb0vo694FNBzCs32PVFKPq/qu+ WsWJBfEp15gE3Cnjcyh/8G26GZyQPjYcKX1U4hnI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Yang Yingliang , John Garry , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.18 0248/1095] bus: hisi_lpc: fix missing platform_device_put() in hisi_lpc_acpi_probe() Date: Mon, 15 Aug 2022 19:54:07 +0200 Message-Id: <20220815180440.034340010@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: Yang Yingliang [ Upstream commit 54872fea6a5ac967ec2272aea525d1438ac6735a ] In error case in hisi_lpc_acpi_probe() after calling platform_device_add(), hisi_lpc_acpi_remove() can't release the failed 'pdev', so it will be leak, call platform_device_put() to fix this problem. I'v constructed this error case and tested this patch on D05 board. Fixes: 99c0228d6ff1 ("HISI LPC: Re-Add ACPI child enumeration support") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang Acked-by: John Garry Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/bus/hisi_lpc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/bus/hisi_lpc.c b/drivers/bus/hisi_lpc.c index 378f5d62a991..e7eaa8784fee 100644 --- a/drivers/bus/hisi_lpc.c +++ b/drivers/bus/hisi_lpc.c @@ -503,13 +503,13 @@ static int hisi_lpc_acpi_probe(struct device *hostdev) { struct acpi_device *adev = ACPI_COMPANION(hostdev); struct acpi_device *child; + struct platform_device *pdev; int ret; /* Only consider the children of the host */ list_for_each_entry(child, &adev->children, node) { const char *hid = acpi_device_hid(child); const struct hisi_lpc_acpi_cell *cell; - struct platform_device *pdev; const struct resource *res; bool found = false; int num_res; @@ -571,22 +571,24 @@ static int hisi_lpc_acpi_probe(struct device *hostdev) ret = platform_device_add_resources(pdev, res, num_res); if (ret) - goto fail; + goto fail_put_device; ret = platform_device_add_data(pdev, cell->pdata, cell->pdata_size); if (ret) - goto fail; + goto fail_put_device; ret = platform_device_add(pdev); if (ret) - goto fail; + goto fail_put_device; acpi_device_set_enumerated(child); } return 0; +fail_put_device: + platform_device_put(pdev); fail: hisi_lpc_acpi_remove(hostdev); return ret; -- 2.35.1