Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3589cce2 authored by Jaejoong Kim's avatar Jaejoong Kim Committed by Felipe Balbi
Browse files

usb: gadget: udc: Use scnprintf() instead of snprintf()



The show() method should use scnprintf() not snprintf() because snprintf()
may returns a value that exceeds its second argument.

Signed-off-by: default avatarJaejoong Kim <climbbb.kim@gmail.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent daaecc65
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1482,7 +1482,7 @@ ssize_t name##_show(struct device *dev, \
		struct device_attribute *attr, char *buf)		\
{									\
	struct usb_udc *udc = container_of(dev, struct usb_udc, dev);	\
	return snprintf(buf, PAGE_SIZE, "%s\n",				\
	return scnprintf(buf, PAGE_SIZE, "%s\n",			\
			usb_speed_string(udc->gadget->param));		\
}									\
static DEVICE_ATTR_RO(name)
@@ -1497,7 +1497,7 @@ ssize_t name##_show(struct device *dev, \
	struct usb_udc		*udc = container_of(dev, struct usb_udc, dev); \
	struct usb_gadget	*gadget = udc->gadget;		\
								\
	return snprintf(buf, PAGE_SIZE, "%d\n", gadget->name);	\
	return scnprintf(buf, PAGE_SIZE, "%d\n", gadget->name);	\
}								\
static DEVICE_ATTR_RO(name)

+1 −1
Original line number Diff line number Diff line
@@ -2366,7 +2366,7 @@ static inline ssize_t show_urb(char *buf, size_t size, struct urb *urb)
{
	int ep = usb_pipeendpoint(urb->pipe);

	return snprintf(buf, size,
	return scnprintf(buf, size,
		"urb/%p %s ep%d%s%s len %d/%d\n",
		urb,
		({ char *s;