Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp707969lqb; Wed, 29 May 2024 08:19:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUenpt+gkZOn271RdyiUHt5hsVtChOH84Yapg1kCoMuQW7k5EvAL9mLYudIYz8ZA4FiiUBp0XLZTSMC2lKVBPZ0B7aDjTzkRy6zHMzhFA== X-Google-Smtp-Source: AGHT+IFtuRtDywctuj4FxFsvRfhu/SmegNCkJOIkR8PicZgLpkQHdDjp/AqLrz2ul2zr+/nsJK/G X-Received: by 2002:a50:9318:0:b0:578:62a8:a5ef with SMTP id 4fb4d7f45d1cf-57862a8a6damr10204184a12.8.1716995953074; Wed, 29 May 2024 08:19:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716995953; cv=pass; d=google.com; s=arc-20160816; b=0XMa5h2ILaTkICe9L4FU49kboP0fkTvshZC2K2MvUxrDhGH4vg42K3MO4tzM9Y2/B8 0J88JqzbUKTerFUXDn3N6STRrvEs4RP8EwP6qdKacKKqZsPk2NrZMZ+31980idXoelAc cmmtmhErIK2tMdX9+M4gBBwcNBNJOANqUkd1BQp+w+hzJA2TgfM5NSHgHlag+TkstXqu ZzjDqlEWFMeknYwpdsF8a/m5J5OcdExOYhuIl7Xs4L7ROuk5MX3goI7OLc5thAquZlBo Yk8ujUIUdtV4hMS49hGxyDwRbRMEPfNFAJ9e7RFpqwcLtL/2Pa0j9cu3GyRhb3sLElj5 amew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :reply-to:content-language:references:cc:to:subject:user-agent :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=IYYsWZqRIFywdpugd83J7K7puOfjrjsQtYUdq85x9iI=; fh=8o106rNVTVQ5YXbLvEs5CSgSSA+MZ4cN8qsO43Zu0Og=; b=YAEYL1cWH+Lx8HrxxBheAxLav4qxkuy3vp+niSIc33ahxLP9op+NZiBjR5/4N5R+t9 mBmxWyFbTxjGiBYI7XIF/y8LP4YT0licha6KcXTE0BOKAg7waMPfBmDb8Yv/Js8GdXgo xyrA3Q0gqAZUupMauWQxF2JAqyfMS+pFIMQYE7jous6INFteE+u40Pm/cTZo9Pruwcgn H3R4rcxFbSHcB+WNeps+6hqtvvApm3QbQ1QtJ9q3T/hcU87sMXWdtwE0bb6rnLpF5sOT CX5sSHsoFQ2rO/l+Q03o2hMDo+fHDvMSXJ2Z1vs6y6BCeGUzDib5X8BKF7YUopHwZEOu IpIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tTwdGxAW; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-194347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194347-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5785245f158si6324631a12.338.2024.05.29.08.19.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 08:19:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tTwdGxAW; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-194347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194347-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 96D281F212CF for ; Wed, 29 May 2024 15:19:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED6CD1802BE; Wed, 29 May 2024 15:18:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="tTwdGxAW" Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCA6A25740 for ; Wed, 29 May 2024 15:18:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716995938; cv=none; b=FfRq7rbKmEB3YFNMick1PiAuBpTqJqPXWKH6RkyWUF9BOU4nyTGZPreZCQp0WZRO/zgBSVIPCMEIlgZg3a+ivDspA+yvgljEZUAgbYz6XbZIQelcqVZyBH40Hsl6gxhB3zio5szwIv8Tm9PYcY+3EofZ1CYOLV4/Z4hM4Tu5FFY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716995938; c=relaxed/simple; bh=e0oscgyefSvmp5LZX6qbQxfiVgd8JKuZUaFHNvmv9mw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rW9EQCi7wMgv5MXcMU6M8qHhXu50lvJGUHvqqK11s4HJ4U7NHlo2aN9LRWkHH+IXxvrXuPBFBsAOILI4i9wQp2OepKwjZPj9xTCexcp+o140LIqdSE1OuKbtlpIJbesqcqjF6wdjsdiyaHFKF1OHXcoLtWDfF0w3R3dJjMRZcN8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=tTwdGxAW; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-420180b5922so25700285e9.2 for ; Wed, 29 May 2024 08:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716995934; x=1717600734; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :reply-to:content-language:references:cc:to:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=IYYsWZqRIFywdpugd83J7K7puOfjrjsQtYUdq85x9iI=; b=tTwdGxAWzX3frcnUJf3icdDYD8Tn6Sbr3LyFP8sE7uCre7WkHQhq4NV0Y7QzT0PsKJ MwHRtfXqHCZiDxUlehaHOK7UJCOMK2HoACg9xRWUNOZ4kdicc3cNxNc29wHxorcgOeIx WJqgjWx/Vqedv/+NQlCFFvCcjJzugUjch2Foha5aqCFYL/qJ3J/uurq2m4Fwhkb4+vRy Ec4PKCY8J3GKEYuZE4s6OBsTqFxd7G8bstbpLgVrTV7PLxtjhZTpJ+J0ulRdCv3erGAC BUJKiz0fTQHbj3H5Ai21jNDWwpa0H6khID5embPTDTVemD0eOc9cUZj8VV2YSK6xNlLd WYKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716995934; x=1717600734; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :reply-to:content-language:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=IYYsWZqRIFywdpugd83J7K7puOfjrjsQtYUdq85x9iI=; b=KudZjEJDFaclyU2vTe0zns0gLmzXWk9oKPqT/V9Oc+w9/r3ld5cwS3JDyqL0nyK81W +0EmNc6Dym63jN559mP/TREtVQCZm/bO94yMy1PYlicoQ+AWQjKKMjzcBEVxBTcIvu6A 0Z3Dr6mkVAiuHhwXPHaPg+HkXSkbktHs3UX5lXZaLBF8Ng9dOjla1qMrG1CVBByWt/bM Nn74VSo4K9tpgqiG7uJfNG4tOwQ2CtTeAPUB6dJlGz2kO47fHFrbzBwJ1yyWHUBwSsG5 IMlfwc/NXsurlvb5kplHvJrIjOynMzVefCrCUTS5QcWF3FjvPP1B18rAvirneQ6Pr/cp ye2g== X-Forwarded-Encrypted: i=1; AJvYcCVbrJiFzmWSkA3/GsHIDh4czSCf7DkOgo/6ZPW8NQS3W0V6trE17rKNz2KGyafTwtoypVmwlTRSHQhVqAdZxkF2UBMC61ZoHmtzMUCd X-Gm-Message-State: AOJu0YzNT3n5zR1iv6cFiDY7pWQm7T4tm3pBixX3IjPxQMroz96MhZyz eAYATDPdryhCv+ARsJXikPPTeC2knfX87mvLXE8n1Z0MBrsRxWDdzdw8cXmt+TA= X-Received: by 2002:adf:e850:0:b0:357:3e5a:6c98 with SMTP id ffacd0b85a97d-3573e5a7b65mr9956014f8f.48.1716995933966; Wed, 29 May 2024 08:18:53 -0700 (PDT) Received: from ?IPV6:2a01:e0a:982:cbb0:8894:9a1b:5e81:c70? ([2a01:e0a:982:cbb0:8894:9a1b:5e81:c70]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3557a090c20sm14968495f8f.62.2024.05.29.08.18.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 May 2024 08:18:53 -0700 (PDT) Message-ID: Date: Wed, 29 May 2024 17:18:52 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] of: property: Fix device_node cleanup To: Alexander Stein , Rob Herring , Saravana Kannan , Shresth Prasad Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240529073246.537459-1-alexander.stein@ew.tq-group.com> Content-Language: en-US, fr Reply-To: neil.armstrong@linaro.org From: Neil Armstrong Autocrypt: addr=neil.armstrong@linaro.org; keydata= xsBNBE1ZBs8BCAD78xVLsXPwV/2qQx2FaO/7mhWL0Qodw8UcQJnkrWmgTFRobtTWxuRx8WWP GTjuhvbleoQ5Cxjr+v+1ARGCH46MxFP5DwauzPekwJUD5QKZlaw/bURTLmS2id5wWi3lqVH4 BVF2WzvGyyeV1o4RTCYDnZ9VLLylJ9bneEaIs/7cjCEbipGGFlfIML3sfqnIvMAxIMZrvcl9 qPV2k+KQ7q+aXavU5W+yLNn7QtXUB530Zlk/d2ETgzQ5FLYYnUDAaRl+8JUTjc0CNOTpCeik 80TZcE6f8M76Xa6yU8VcNko94Ck7iB4vj70q76P/J7kt98hklrr85/3NU3oti3nrIHmHABEB AAHNKk5laWwgQXJtc3Ryb25nIDxuZWlsLmFybXN0cm9uZ0BsaW5hcm8ub3JnPsLAkQQTAQoA OwIbIwULCQgHAwUVCgkICwUWAgMBAAIeAQIXgBYhBInsPQWERiF0UPIoSBaat7Gkz/iuBQJk Q5wSAhkBAAoJEBaat7Gkz/iuyhMIANiD94qDtUTJRfEW6GwXmtKWwl/mvqQtaTtZID2dos04 YqBbshiJbejgVJjy+HODcNUIKBB3PSLaln4ltdsV73SBcwUNdzebfKspAQunCM22Mn6FBIxQ GizsMLcP/0FX4en9NaKGfK6ZdKK6kN1GR9YffMJd2P08EO8mHowmSRe/ExAODhAs9W7XXExw UNCY4pVJyRPpEhv373vvff60bHxc1k/FF9WaPscMt7hlkbFLUs85kHtQAmr8pV5Hy9ezsSRa GzJmiVclkPc2BY592IGBXRDQ38urXeM4nfhhvqA50b/nAEXc6FzqgXqDkEIwR66/Gbp0t3+r yQzpKRyQif3OwE0ETVkGzwEIALyKDN/OGURaHBVzwjgYq+ZtifvekdrSNl8TIDH8g1xicBYp QTbPn6bbSZbdvfeQPNCcD4/EhXZuhQXMcoJsQQQnO4vwVULmPGgtGf8PVc7dxKOeta+qUh6+ SRh3vIcAUFHDT3f/Zdspz+e2E0hPV2hiSvICLk11qO6cyJE13zeNFoeY3ggrKY+IzbFomIZY 4yG6xI99NIPEVE9lNBXBKIlewIyVlkOaYvJWSV+p5gdJXOvScNN1epm5YHmf9aE2ZjnqZGoM Mtsyw18YoX9BqMFInxqYQQ3j/HpVgTSvmo5ea5qQDDUaCsaTf8UeDcwYOtgI8iL4oHcsGtUX oUk33HEAEQEAAcLAXwQYAQIACQUCTVkGzwIbDAAKCRAWmrexpM/4rrXiB/sGbkQ6itMrAIfn M7IbRuiSZS1unlySUVYu3SD6YBYnNi3G5EpbwfBNuT3H8//rVvtOFK4OD8cRYkxXRQmTvqa3 3eDIHu/zr1HMKErm+2SD6PO9umRef8V82o2oaCLvf4WeIssFjwB0b6a12opuRP7yo3E3gTCS KmbUuLv1CtxKQF+fUV1cVaTPMyT25Od+RC1K+iOR0F54oUJvJeq7fUzbn/KdlhA8XPGzwGRy 4zcsPWvwnXgfe5tk680fEKZVwOZKIEuJC3v+/yZpQzDvGYJvbyix0lHnrCzq43WefRHI5XTT QbM0WUIBIcGmq38+OgUsMYu4NzLu7uZFAcmp6h8g Organization: Linaro In-Reply-To: <20240529073246.537459-1-alexander.stein@ew.tq-group.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 29/05/2024 09:32, Alexander Stein wrote: > '__free(device_node)' attached to remote will cause a double release: >> OF: ERROR: of_node_release() detected bad of_node_put() on >> /soc@0/bus@32c00000/dsi@32e60000 > > In case remote is to be returned it must not be cleaned up by a call > to of_node_put. The caller has to do that as the documentation mentions. > Partly revert commit b94d24c08ee1a ("of: property: Remove calls to > of_node_put") to fix it. > > Fixes: b94d24c08ee1 ("of: property: Remove calls to of_node_put") > Signed-off-by: Alexander Stein > --- > I get the following trace starting with next-20240529: > > OF: ERROR: of_node_release() detected bad of_node_put() on /soc@0/bus@32c00000/dsi@32e60000 > CPU: 0 PID: 11 Comm: kworker/u16:0 Not tainted 6.10.0-rc1-next-20240529+ #2511 610eecbb638fc5fab9a27e01b78203e8a379a280 > Hardware name: TQ-Systems i.MX8MPlus TQMa8MPxL on MBa8MPxL (DT) > Workqueue: events_unbound deferred_probe_work_func > Call trace: > dump_backtrace+0x90/0x10c > show_stack+0x14/0x1c > dump_stack_lvl+0x6c/0x80 > dump_stack+0x14/0x1c > of_node_release+0x11c/0x188 > kobject_cleanup+0x48/0x17c > kobject_put+0x78/0xc0 > of_node_put+0x14/0x20 > drm_of_find_panel_or_bridge+0x84/0xd4 > devm_drm_of_get_bridge+0x3c/0x8c > lcdif_attach_bridge+0x88/0x270 > lcdif_load+0x144/0x28c > lcdif_probe+0x34/0xcc > platform_probe+0x64/0xe8 > really_probe+0xc8/0x3ac > __driver_probe_device+0x84/0x188 > driver_probe_device+0x38/0x150 > __device_attach_driver+0xcc/0x194 > bus_for_each_drv+0x80/0xdc > __device_attach+0x9c/0x1d0 > device_initial_probe+0x10/0x18 > bus_probe_device+0xa4/0xa8 > deferred_probe_work_func+0x9c/0xe8 > process_one_work+0x154/0x3fc > worker_thread+0x2f4/0x404 > kthread+0xf4/0x100 > ret_from_fork+0x10/0x20 > OF: ERROR: next of_node_put() on this node will result in a kobject warning 'refcount_t: underflow; use-after-free.' > ------------[ cut here ]------------ > refcount_t: addition on 0; use-after-free. > WARNING: CPU: 0 PID: 11 at lib/refcount.c:25 refcount_warn_saturate+0x150/0x214 > Modules linked in: > CPU: 0 PID: 11 Comm: kworker/u16:0 Not tainted 6.10.0-rc1-next-20240529+ #2511 610eecbb638fc5fab9a27e01b78203e8a379a280 > Hardware name: TQ-Systems i.MX8MPlus TQMa8MPxL on MBa8MPxL (DT) > [...] > > drivers/of/property.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/of/property.c b/drivers/of/property.c > index 83536216ed4fe..e5c6301643e4c 100644 > --- a/drivers/of/property.c > +++ b/drivers/of/property.c > @@ -836,9 +836,7 @@ struct device_node *of_graph_get_remote_node(const struct device_node *node, > { > struct device_node *endpoint_node __free(device_node) = > of_graph_get_endpoint_by_regs(node, port, endpoint); > - > - struct device_node *remote __free(device_node) = > - of_graph_get_remote_port_parent(endpoint_node); > + struct device_node *remote; > > if (!endpoint_node) { > pr_debug("no valid endpoint (%d, %d) for node %pOF\n", > @@ -846,6 +844,7 @@ struct device_node *of_graph_get_remote_node(const struct device_node *node, > return NULL; > } > > + remote = of_graph_get_remote_port_parent(endpoint_node); > if (!remote) { > pr_debug("no valid remote node\n"); > return NULL; > @@ -853,6 +852,7 @@ struct device_node *of_graph_get_remote_node(const struct device_node *node, > > if (!of_device_is_available(remote)) { > pr_debug("not available for remote node\n"); > + of_node_put(remote); > return NULL; > } > Tested-by: Neil Armstrong # on SM8650-QRD