From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f49.google.com (mail-dl1-f49.google.com [74.125.82.49]) (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 519D22EBBAF for ; Wed, 1 Apr 2026 02:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775009368; cv=none; b=DlrG+VSyu0kaVl9TelCAA64oisfp9+DUHnLJcIsWmuAEiMOPDsLskNz3dLy31pBVe/BTQ6AjsDfii3V6JgOHsZtBslhDtcXxhP1LHoGWds2NPMKXwkGIdY/9F0CR4/NcFBwi4a7CGweFZQuD1Ixi8VkC41YA8PLBP02pWCLghVM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775009368; c=relaxed/simple; bh=2R6lpriRiJyGfdxQxsSHGdyW9OvyN2xr4NV/z7YXTK0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iKP66MH7LwEXzySCsDHkzu7uVj8w9pinxSh48qGADyt4G23NbxSMbyLJXyNYmfGjlLIKypXGfntNl65iiccHHeXYMIHEflUqalyeXjswwyRAbncdal66gnkCWUvwX28ojAHgLsW5WvBe7IYErEemj7omWrBeLi5JwHTZNC2Il6o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KB64mDUt; arc=none smtp.client-ip=74.125.82.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KB64mDUt" Received: by mail-dl1-f49.google.com with SMTP id a92af1059eb24-126ea4b77adso9097053c88.1 for ; Tue, 31 Mar 2026 19:09:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775009365; x=1775614165; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rsoAviV2wZmke+4BsttL3YCzfWLi9sYU1xca+C62Oc0=; b=KB64mDUt/6LvxBBo7pky2a4+83zjiHQl09bIvdr6xOm/D5tWedOFTuMbH5Cn2RH6ty 0nunWApA/l+UMNjcYARLfIaog14IG+oGQlGwhe3uXc7KlWAnWiwkfedhKV/my/Iw+mg5 ZxFCqzG2TkXtf3XJDiWEMLjGd5HURepY3sElQxuwPFhskJlBFE2lcH0up2pMuVuc7AXd 3gi+0QMQK50lS68YRdp+0RcnybIvCjzJsvS8DwWcFcv5RP0RtqJxtSxLstE5k53Qcqxo M6+34vPUFbOU4TnX2HvM5R4vKNuRx+HaajBfP6+SIR7pk+Mc90/uS45RKqaXmfajHVT1 Niug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775009365; x=1775614165; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rsoAviV2wZmke+4BsttL3YCzfWLi9sYU1xca+C62Oc0=; b=Bj4m9oXnY94rfOBev504UKf0CAkcXiGVPrUXDCAB+G7thgrn+vDWj26eON+AqxhDpN ITPrt2Ez72EhJV5Hcj6CkK+21hEtNedHp3Oqf7gl8XTFPfCapcR47Y+q6vCJoUOAvmo8 QdUl3uqraSxvuG1p826kVHadWuGNp0SqsB053F8SkmtM1OUkOzQCao6VH6hW4zk2NKyf /y6lYLJxskwKXJxkTQFWMtCIH3RG/GSDMRcS05zNX7Djc2PoZ/JSHbcgk0z26cEZtITT hai3NfJtr7Q55+rDPfjrBkR2lXBx7JgqQLF620GQLFdbHZ35xV2xeV8TEgRiX23FfDJ3 EUSw== X-Forwarded-Encrypted: i=1; AJvYcCWgVioUHPmZXqsRbKqC914gu2ps96n5vo9byv+1tC986diGzs0lE2h3L+PqSymEWGOJCGMiykvSW2siQD4=@vger.kernel.org X-Gm-Message-State: AOJu0YyqJEKOI4x8ikkQD03D76fbeEoQL863T91u0WSD+v7rSk/P1v2P WO60t+FQMLn2U4qFTe/QU+uydbQU2cWgeIKmpszgfV3cy4s0RxFfzdNz X-Gm-Gg: ATEYQzx4HoIdcoLkFm9Nwu8OQjV37LdF5cmQ4cQqB+6a3d0uDh/z5dYrxrNSqxPZD4M lPfFaN7w1D5SzkX3N69YooIAIux4f4479TTNjLLy6qRQgFua8tw5vk/jmGH64zbPnQq9i+Kd6Hp 9y9egjKVk31pfk192Ph68zlWKBvgvzFxV+lRwmtWy7yqUmavCcsByzSk9U3svvkFWDT2S4C0e7j j+pLJpcgHfl4ln77PC7ZHl5A83WBnPZspe5+xb1xl48n2erdGW+7iqbUIalry/KZQiuGRVYgaZ0 yJS+XVkKMvmADyaohGWjskTNqkj2t4KTgJ0q7BpJiW5IhX0fQJRodk7GmZtk8obFKW5iYxS0g27 fyDu/pAkBVYRX1J0LEVkMpqAk7yC+ScPsvoB5Z/b8Ofe9fUVjmuJu0uviPhE/Pfm9pwpGCxzQGr iA67vg7FmlhEtEDVUi58EAJmAohDQrGI/UfLDfP5UpofpBSbnAUPQ7NGQyRtFqQTHv X-Received: by 2002:a05:7022:602:b0:128:d2f2:5cf8 with SMTP id a92af1059eb24-12be6575e03mr1074170c88.34.1775009365163; Tue, 31 Mar 2026 19:09:25 -0700 (PDT) Received: from google.com ([2a00:79e0:2ebe:8:1dbf:b0e0:8ad0:5a2e]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12abde65313sm11136129c88.14.2026.03.31.19.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 19:09:24 -0700 (PDT) Date: Tue, 31 Mar 2026 19:09:21 -0700 From: Dmitry Torokhov To: Bartosz Golaszewski Cc: Santosh Kumar Yadav , Peter Korsgaard , Hans de Goede , Ilpo =?utf-8?B?SsOkcnZpbmVu?= , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, brgl@kernel.org Subject: Re: [PATCH] platform/x86: barco-p50-gpio: attach software node to its target GPIO device Message-ID: References: <20260331112819.103298-1-bartosz.golaszewski@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260331112819.103298-1-bartosz.golaszewski@oss.qualcomm.com> On Tue, Mar 31, 2026 at 01:28:19PM +0200, Bartosz Golaszewski wrote: > The software node representing the GPIO controller to consumers is > "dangling": it's not really attached to the device. The GPIO lookup > relies on matching the name of the node to the chip's label. Set it as > the secondary firmware node of the platform device to enable proper > fwnode-based GPIO lookup. > > Signed-off-by: Bartosz Golaszewski > --- > drivers/platform/x86/barco-p50-gpio.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/platform/x86/barco-p50-gpio.c b/drivers/platform/x86/barco-p50-gpio.c > index 2a6d8607c402..5f4ffa584295 100644 > --- a/drivers/platform/x86/barco-p50-gpio.c > +++ b/drivers/platform/x86/barco-p50-gpio.c > @@ -365,6 +365,8 @@ static int p50_gpio_probe(struct platform_device *pdev) > if (ret) > return dev_err_probe(&pdev->dev, ret, "failed to register software nodes"); > > + set_secondary_fwnode(&pdev->dev, software_node_fwnode(&gpiochip_node)); > + > led_info.fwnode = software_node_fwnode(&gpio_leds_node); > p50->leds_pdev = platform_device_register_full(&led_info); > if (IS_ERR(p50->leds_pdev)) { I looks like http://sashiko.dev patch critique is on point: " Is the software node attached too late to take effect? In the probe function, devm_gpiochip_add_data() is called before this set_secondary_fwnode() call. During GPIO chip registration, the gpiolib core snapshots the parent device's fwnode. Because the secondary fwnode is not yet set on pdev->dev when this snapshot happens, the GPIO device is registered with a NULL fwnode, which seems to defeat the purpose of enabling fwnode-based lookups. If the order is reversed, would we need to tie the software node registration to devres (e.g., via devm_add_action_or_reset)? Otherwise, a manual software_node_unregister_node_group() in the probe error path might free the software node while the devm-managed gpiochip still holds a pointer to it. Additionally, could this leave a dangling pointer on probe failure or driver unbind? If a subsequent step fails (like registering keys_pdev), the probe error path calls software_node_unregister_node_group(p50_swnodes), which frees the underlying memory. Because set_secondary_fwnode(&pdev->dev, NULL) is never called to clear it, pdev->dev.fwnode would point to freed memory. Any subsequent access to the device's firmware node could trigger a use-after-free. " Thanks. -- Dmitry