]> git.baikalelectronics.ru Git - kernel.git/commit
usb: gadget: function: fix dangling pnp_string in f_printer.c
authorAlbert Briscoe <albertsbriscoe@gmail.com>
Sun, 11 Sep 2022 22:37:55 +0000 (15:37 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Sep 2022 13:52:29 +0000 (15:52 +0200)
commit308defc0ae6bc2cb6dccb7ba47d777bf3136760f
treefa48ba5d85753139ae8d4713f61b0b7a289ed699
parentf6dd6698ad86ef5d9020980d114764cf33286ecb
usb: gadget: function: fix dangling pnp_string in f_printer.c

When opts->pnp_string is changed with configfs, new memory is allocated for
the string. It does not, however, update dev->pnp_string, even though the
memory is freed. When rquesting the string, the host then gets old or
corrupted data rather than the new string. The ieee 1284 id string should
be allowed to change while the device is connected.

The bug was introduced in commit 0d60940f97f0 ("usb: gadget: printer:
Remove pnp_string static buffer"), which changed opts->pnp_string from a
char[] to a char*.
This patch changes dev->pnp_string from a char* to a char** pointing to
opts->pnp_string.

Fixes: 0d60940f97f0 ("usb: gadget: printer: Remove pnp_string static buffer")
Signed-off-by: Albert Briscoe <albertsbriscoe@gmail.com>
Link: https://lore.kernel.org/r/20220911223753.20417-1-albertsbriscoe@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_printer.c