]> git.proxmox.com Git - mirror_ubuntu-jammy-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)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 24 Nov 2022 13:24:40 +0000 (14:24 +0100)
commit5edef2db17c858926a6aaa869c0de8dd2a8fb445
treeefadb71ba5b31d43dfe9be1867d9a8315797df70
parent8688365d04d5c9cfafa327802d449bf4f738f8c2
usb: gadget: function: fix dangling pnp_string in f_printer.c

BugLink: https://bugs.launchpad.net/bugs/1996825
[ Upstream commit 24b7ba2f88e04800b54d462f376512e8c41b8a3c ]

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 fdc01cc286be ("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: fdc01cc286be ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/usb/gadget/function/f_printer.c