]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: typec: altmodes/displayport: create sysfs nodes as driver's default device attri...
authorRD Babiera <rdbabiera@google.com>
Thu, 29 Feb 2024 00:11:02 +0000 (00:11 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 May 2025 12:08:27 +0000 (14:08 +0200)
commit9794ffd9d0c39ee070fbd733f862bbe89b28ba33
tree4a824357b2170235ea985b4838e435ae035321b9
parentf4bd982563c2fd41ec9ca6c517c392d759db801c
usb: typec: altmodes/displayport: create sysfs nodes as driver's default device attribute group

commit 165376f6b23e9a779850e750fb2eb06622e5a531 upstream.

The DisplayPort driver's sysfs nodes may be present to the userspace before
typec_altmode_set_drvdata() completes in dp_altmode_probe. This means that
a sysfs read can trigger a NULL pointer error by deferencing dp->hpd in
hpd_show or dp->lock in pin_assignment_show, as dev_get_drvdata() returns
NULL in those cases.

Remove manual sysfs node creation in favor of adding attribute group as
default for devices bound to the driver. The ATTRIBUTE_GROUPS() macro is
not used here otherwise the path to the sysfs nodes is no longer compliant
with the ABI.

Fixes: 0e3bb7d6894d ("usb: typec: Add driver for DisplayPort alternate mode")
Cc: stable@vger.kernel.org
Signed-off-by: RD Babiera <rdbabiera@google.com>
Link: https://lore.kernel.org/r/20240229001101.3889432-2-rdbabiera@google.com
[Minor conflict resolved due to code context change.]
Signed-off-by: Jianqi Ren <jianqi.ren.cn@windriver.com>
Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/altmodes/displayport.c