phy: renesas: rcar-gen3-usb2: Fix sysfs interface of "role"
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Mon, 7 Oct 2019 07:55:10 +0000 (16:55 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Dec 2019 19:07:27 +0000 (20:07 +0100)
commit33e3c9187ddfb8f44f0758a9584c87f735bebaf5
treeec39f5326f9b738003a8364482d7920bc9000ee0
parenteae68719695d059e02d7eef0485cf1d9248caa5a
phy: renesas: rcar-gen3-usb2: Fix sysfs interface of "role"

commit 4bd5ead82d4b877ebe41daf95f28cda53205b039 upstream.

Since the role_store() uses strncmp(), it's possible to refer
out-of-memory if the sysfs data size is smaller than strlen("host").
This patch fixes it by using sysfs_streq() instead of strncmp().

Reported-by: Pavel Machek <pavel@denx.de>
Fixes: 9bb86777fb71 ("phy: rcar-gen3-usb2: add sysfs for usb role swap")
Cc: <stable@vger.kernel.org> # v4.10+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/phy/renesas/phy-rcar-gen3-usb2.c