Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1732260rdb; Tue, 20 Feb 2024 05:36:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXZ0RiJbxqv1kMj/Fpg8XpVYeD4+GtPBNbymtNhQQcxa6wgutzZPRTeTDGa61mxK5C3/VnJcnNTjzvGtD3JxzGtMZbRWLL4P2wOJu0wnw== X-Google-Smtp-Source: AGHT+IEjpoGEtdejpQyGVFRtN5u2B40ajuT2Ip8DxIXKcCJmh0J5pom7WaPT/kuwZ+ZMtthVbq38 X-Received: by 2002:a05:622a:1714:b0:42c:6eb2:b1c1 with SMTP id h20-20020a05622a171400b0042c6eb2b1c1mr20665333qtk.16.1708436162829; Tue, 20 Feb 2024 05:36:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708436162; cv=pass; d=google.com; s=arc-20160816; b=q9HHQoIJZ/ggIPjB4p+joZ7Skb8A70bWwvxI0Apjr8piqpMlT2qyfxmrw0Va4RN1rh cdS9VmVPm3aR0Ul7rn1dC3n6yXaWpTRrW+K3eGAO7CL1WJymEhvT7Yo1MPqX1sfae8nH j9DEPn0kZ7sMmZrWSPLuH79/omsc3aRiEpA0XHNkAMQ5M9TAwZB757XTzwpHU6ngggWa sbfXWZGgFx5hLW5xrDyIhLqVnnYkMbJwVwu1pCcfcsepFaa8kexnB7hl+CMshvGFkPec yUgeL7HbKidmBOCNMMm3CaYaHyQKflRXacR63C8iAVMj74kaMHhNBO+u558EHOwaMF0P 22ow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=80bDR9xsJVYz/T1iI+xnPV8UhHBUEFxKf9UJFof0JFA=; fh=4jXbGb0V8024vzZK6cY0/v02fkRe0CoUzx7zqWYLrTc=; b=h3U+Qz/vaDzwS+Zq4vhzAb/Xh203VXI6WuYTqZ2CbJV8KVaqvqz6kZ48UgDMjkx/39 YuSVjJDS7Pm/ZaoUwlc7bwGa/gd52a4duGVqJ5M0y4ldZxYFn0vGLXo9haE/A80e2xRu KY3uh1XApEtHu3SJTp8wWFPwV+MW/6tUrlYEROY0+J4GUfqjhRxz/IQI42Oeozpprujz qS0Nuuu0BrEVTRmqvk1RoCHk3oZdKZjIb+Rxq+iyQLiq748porzfu3Rs6v8EFJ4mwz3w Zk+qHWJcUx3ilFGSMF342ZSW4PhaW2B5Acf5N5xSrnnmrnScVTTpY3uQcRjt1zB4S2ex RtsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SeIyDTBF; 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-73080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73080-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d21-20020a05622a15d500b0042c573da17asi9137279qty.638.2024.02.20.05.36.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 05:36:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SeIyDTBF; 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-73080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73080-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8475D1C224ED for ; Tue, 20 Feb 2024 13:36:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AA926A35E; Tue, 20 Feb 2024 13:35:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SeIyDTBF" Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 5DB1C6A331 for ; Tue, 20 Feb 2024 13:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708436150; cv=none; b=Vjnsg0Pfa4F5N0IX1dJI2AIoWOiQSUUCMCtUdpSC8+Hl3aTXMfAfrA/l9ksEppsRdVFbAKeJagsu2BvC8GcbE0osyCbi5z8tXx94P3FDKM3YJoN35TxYbzQGvBIget4h1UvGKC3H4OUE+f259tccCH3KFyao/gKsBFVSFTK5RqQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708436150; c=relaxed/simple; bh=uP9yFWGRb+3k9SdvwFsut4JNqwQGECYNGZVyusotfXA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XXjJXseX6/reVa2wPOG7TigFOVS9Ix9Ojax9qZ8g7o0fofPXQYl+dvYUXbz5m47nZLQjteC09aVO4m5V63GneFuOACnqFwHs35wDie5a7MymZ3ThRgbTj0p0eIAIfGDfUNPcGA1sVgPVONtGOTjLdWeGJLrkQY/Hxl+8zWqP+tQ= 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=SeIyDTBF; arc=none smtp.client-ip=209.85.128.181 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-yw1-f181.google.com with SMTP id 00721157ae682-60821e8d625so23657227b3.1 for ; Tue, 20 Feb 2024 05:35:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708436147; x=1709040947; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=80bDR9xsJVYz/T1iI+xnPV8UhHBUEFxKf9UJFof0JFA=; b=SeIyDTBFpArYr0K/IB/aSKXP/XL8oL/z41ipI4fIwcxu84apF8LgPhF0jYn29ye4z+ KsEyCPyIE9+pSGSzZ1ybMcS2p1xvoFPS4zPKVyVw8v6WMVFtplPREUgIvPhpDECfMl7Y AiZAn2FrMZoBkLgqrqjGfNfKn8RRu7VF7YLpmUIIbwCIZiLHxf7gnIczhPDejV3ZV+KZ zpTi2ZUpo4+EsGjlxRg8jiYRY8d8/ypTAvlf8/Iky0EaVPQCs6mG9bd1CSC6yDpXlX38 dC32vn77lngrpKO+7SpQlEYjrwhYXZjyW7YGYZdLpSY6M4D1i/bdYF9vgbNQmCr+HeTO gJUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708436147; x=1709040947; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=80bDR9xsJVYz/T1iI+xnPV8UhHBUEFxKf9UJFof0JFA=; b=lsGVFC8iUBFQas1R1lwPFRKIfRo5MfDlsIB2cY5+A0jKKi+MOZx+PJDryyenmww6Gh 4CbHg8mujnIj8hmpel4+bE/RrNS2yQE8hMBrPJOAO7g5GCJFPKLpOx5oIi906SGVPoew UgDv+GSeidIgsusrLdFtQIRWnUvrYGgA43oHlKsDlH0PzBI1lQExcP+Vfwa16hkQkQ9S 7orcAWXy9HEjv/vAYIlpfE9k1zWQLAUZLjQGxWNQZilxE+y3A0Nm8l1ySkPhMOLPUG00 5NmBUsy/ocFaL9pPnZU7qASpeEquHXcFJZbemVPwlN8xA59sCDDh86qw9y/ycKTzNXnA S7Sg== X-Forwarded-Encrypted: i=1; AJvYcCVdoMDFT0wGW8r1D7zAC81zKeDrbn/mXkrlGe/3w9Tg7dVGMG7avUP8zHpvPWXnzuelIi+7LIKYKXVnKswuf2BP/7UwiQYHHJ+IqPma X-Gm-Message-State: AOJu0YyixW1ZXuiXPNlSY033HHADUxFrq7MphrPVRqsTiiVBlhElgFvu CnL6xHyrr5yQvHmO6OQx/3ZoqFJeRlulkfsxmJqVoGB7oxf9vinnSkO7az/oJ6HgU6xifB3l3ew vFhUwLvEqGfgLFCtPW4gJ3YnwkcifbJv6++kDWw== X-Received: by 2002:a81:7994:0:b0:607:7e73:fce1 with SMTP id u142-20020a817994000000b006077e73fce1mr16601552ywc.26.1708436146800; Tue, 20 Feb 2024 05:35:46 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240217150228.5788-2-johan+linaro@kernel.org> <1afc87c-2c1f-df10-a0c8-2a267d44122@inria.fr> <4938592e-3f7c-c1ae-dce3-fd1ca363296@inria.fr> In-Reply-To: <4938592e-3f7c-c1ae-dce3-fd1ca363296@inria.fr> From: Dmitry Baryshkov Date: Tue, 20 Feb 2024 15:35:35 +0200 Message-ID: Subject: Re: [PATCH 1/6] drm/bridge: aux-hpd: fix OF node leaks To: Julia Lawall Cc: Johan Hovold , Markus Elfring , Johan Hovold , freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-phy@lists.infradead.org, linux-arm-msm@vger.kernel.org, kernel-janitors@vger.kernel.org, Andrzej Hajda , Bjorn Andersson , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Neil Armstrong , Robert Foss , Thomas Zimmermann , Vinod Koul , LKML , Abhinav Kumar , Jernej Skrabec , Jonas Karlman , Kishon Vijay Abraham I , Konrad Dybcio , Kuogee Hsieh , Laurent Pinchart , Rob Clark Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 20 Feb 2024 at 14:56, Julia Lawall wrote: > > > > On Tue, 20 Feb 2024, Dmitry Baryshkov wrote: > > > On Tue, 20 Feb 2024 at 13:52, Julia Lawall wrot= e: > > > > > > > > > > > > On Tue, 20 Feb 2024, Johan Hovold wrote: > > > > > > > On Mon, Feb 19, 2024 at 06:48:30PM +0100, Markus Elfring wrote: > > > > > > The two device node references taken during allocation need to = be > > > > > > dropped when the auxiliary device is freed. > > > > > =E2=80=A6 > > > > > > +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c > > > > > =E2=80=A6 > > > > > > @@ -74,6 +75,8 @@ struct device *drm_dp_hpd_bridge_register(str= uct device *parent, > > > > > > > > > > > > ret =3D auxiliary_device_init(adev); > > > > > > if (ret) { > > > > > > + of_node_put(adev->dev.platform_data); > > > > > > + of_node_put(adev->dev.of_node); > > > > > > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > > > > > > kfree(adev); > > > > > > return ERR_PTR(ret); > > > > > > > > > > The last two statements are also used in a previous if branch. > > > > > https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/gpu/drm/= bridge/aux-hpd-bridge.c#L63 > > > > > > > > > > How do you think about to avoid such a bit of duplicate source co= de > > > > > by adding a label here? > > > > > > > > No, the current code is fine and what you are suggesting is in any = case > > > > unrelated to this fix. > > > > > > > > If this function ever grows a third error path like that, I too wou= ld > > > > consider it however. > > > > > > I guess these of_node_puts can all go away shortly with cleanup anywa= y? > > > > I'm not sure about it. Those are long-living variables, so they are > > not a subject of cleanup.h, are they? > > OK, I didn't look at this code in detail, but cleanup would just call > of_node_put, not actually free the data. Yes. The nodes should be put either in case of the failure or (if everything goes fine) at the device unregistration. --=20 With best wishes Dmitry