]> git.baikalelectronics.ru Git - kernel.git/commit
usb: typec: pi3usb30532: Set switch_ / mux_desc name field to NULL
authorHans de Goede <hdegoede@redhat.com>
Tue, 14 Apr 2020 13:33:13 +0000 (15:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Apr 2020 12:52:09 +0000 (14:52 +0200)
commit3a96bb44d7f63af8465d1d6ef85596813668c27d
treed90b25575e065da48b2168120ee767379bb900ac
parentfe16f28e0ef1736efc65c0c84e0a0a92d1303ae1
usb: typec: pi3usb30532: Set switch_ / mux_desc name field to NULL

Since commit 884802fd7e95 ("usb: typec: mux: Allow the muxes to be named")
the typec_switch_desc and typec_mux_desc structs contain a name field.

The pi3usb30532 driver allocates these structs on the stack and so far did
not explicitly zero the mem used for the structs. This causes the new name
fields to point to a random memory address, which in my test case happens
to be a valid address leading to "interesting" mux / switch names:

[root@localhost ~]# ls -l /sys/class/typec_mux/
total 0
lrwxrwxrwx. 1 root root 0 Apr 14 12:55 ''$'\r''-switch' -> ...
lrwxrwxrwx. 1 root root 0 Apr 14 12:55 ''$'\320\302\006''2'$'...

Explicitly initialize the structs to zero when declaring them on the stack
so that any unused fields get set to 0, fixing this.

Fixes: 884802fd7e95 ("usb: typec: mux: Allow the muxes to be named")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20200414133313.131802-1-hdegoede@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/mux/pi3usb30532.c