Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3729245pxb; Mon, 24 Jan 2022 16:31:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2zbkf+q5YjruvUKprNl2EXiSO0t+THI7/XRlaPbbHqBzX0c0SbdX8B/PElhfCTdAcAWD5 X-Received: by 2002:a17:902:6b05:b0:14a:b331:d07b with SMTP id o5-20020a1709026b0500b0014ab331d07bmr16679990plk.172.1643070714351; Mon, 24 Jan 2022 16:31:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643070714; cv=none; d=google.com; s=arc-20160816; b=YBg6i+McTvD8jaD/RgAJNfTFD/xS0/SsHob81ULKNJPZfaDrR9MhdrGT9g7dtkZYPb sGeAlNNAzdNS6IcUECWeDYPGPPE+jgSDslVzjzh6vbVpKCTGVAjyILGRuwjPql8SzRIK XiSgCPDM8QsAVXH6YHZknmnD8EyqQYaI5MHIhjDIKlB45C+8VB9gSVKs68gWQfiiIcbU V67gzxH5mlgr62vUfbAPs2OTFKr662Jq2A3p3GyND651lfDxrRRn1GKhghkOdkphfCbo PrGxtXOe8VJZpJW+Nhcfjdh5MgfMJSyffiSQGx+KRCShWL1OraTAZLTBkC0KV6xAMlyZ Gvyg== 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=KivO4IcF2nAqaMQ1dhBxO0X0vomxq3yyFqWZhHXPods=; b=yEmW36KY3S/zLG4zIyDB6FtAAq73b05haGxFOqUIA1McoU4h3gVtX9NOaAoni37rit UbvppEnLvNw9LYfCyd016pAkOvrm3TJCgVidsMUDQR9JjnbSI4/WYIKhIHverPdQAmJi DYQWdr7z543Qs4glkbBLdznCYHNOIzM2+nl5RKixuPnShab5W3hD3j1kCkDKOnGO0PNo hTubSmgPwnO+VK/I9CEmnq6NaIhWHcFJLw2YJbqWCMFW1efpyjQhuI3NdBEXrPQuRE8Q mdK6Lz0rwwxjCFOjuCA++AfHOpq1P5vXPW29kZDMk/cFTl1UoQEuvivU39qeETFrEu7K JySQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="KTKNQqc/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t62si6702537pgd.601.2022.01.24.16.31.42; Mon, 24 Jan 2022 16:31:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="KTKNQqc/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S3410231AbiAYA2s (ORCPT + 99 others); Mon, 24 Jan 2022 19:28:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381862AbiAXXeJ (ORCPT ); Mon, 24 Jan 2022 18:34:09 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20B4AC07597A; Mon, 24 Jan 2022 13:35:59 -0800 (PST) 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 B5D2361028; Mon, 24 Jan 2022 21:35:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B32D4C340E5; Mon, 24 Jan 2022 21:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060158; bh=y2surFG9CF99niOXP/oloofbrzQ/roUtKTzGdU8adRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KTKNQqc/PUu1yYpsOUx1sxCLe9s80XRil/hWWFv3SUiDNfoMMNaNaZJWoEWJ9fLHQ FD+83/pjTyqoBjxvWifTsAvPuJ1J0vWWc4uuD9+ICc3sQuE6F2ZANRdZyd37fDndpf 33XZPmrkod4Gk35ZvMEowDHqTuxy9w0xct4kuXs4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sakari Ailus , Andy Shevchenko , "Rafael J. Wysocki" Subject: [PATCH 5.16 0858/1039] device property: Fix fwnode_graph_devcon_match() fwnode leak Date: Mon, 24 Jan 2022 19:44:07 +0100 Message-Id: <20220124184154.119883333@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sakari Ailus commit 4a7f4110f79163fd53ea65438041994ed615e3af upstream. For each endpoint it encounters, fwnode_graph_devcon_match() checks whether the endpoint's remote port parent device is available. If it is not, it ignores the endpoint but does not put the reference to the remote endpoint port parent fwnode. For available devices the fwnode handle reference is put as expected. Put the reference for unavailable devices now. Fixes: 637e9e52b185 ("device connection: Find device connections also from device graphs") Cc: 5.1+ # 5.1+ Signed-off-by: Sakari Ailus Reviewed-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/base/property.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1206,8 +1206,10 @@ fwnode_graph_devcon_match(struct fwnode_ fwnode_graph_for_each_endpoint(fwnode, ep) { node = fwnode_graph_get_remote_port_parent(ep); - if (!fwnode_device_is_available(node)) + if (!fwnode_device_is_available(node)) { + fwnode_handle_put(node); continue; + } ret = match(node, con_id, data); fwnode_handle_put(node);