mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-04 18:19:28 +09:00
usb: gadget: udc: renesas_usb3: Fix sysfs interface of "role"
commit5dac665cf4upstream. 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(). Fixes:cc995c9ec1("usb: gadget: udc: renesas_usb3: add support for usb role swap") Cc: <stable@vger.kernel.org> # v4.12+ Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
282a771475
commit
56a3eb5fa5
@@ -21,6 +21,7 @@
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/sizes.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/sys_soc.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/usb/ch9.h>
|
||||
@@ -2315,9 +2316,9 @@ static ssize_t role_store(struct device *dev, struct device_attribute *attr,
|
||||
if (usb3->forced_b_device)
|
||||
return -EBUSY;
|
||||
|
||||
if (!strncmp(buf, "host", strlen("host")))
|
||||
if (sysfs_streq(buf, "host"))
|
||||
new_mode_is_host = true;
|
||||
else if (!strncmp(buf, "peripheral", strlen("peripheral")))
|
||||
else if (sysfs_streq(buf, "peripheral"))
|
||||
new_mode_is_host = false;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
Reference in New Issue
Block a user