Skip to contentSkip to conversation

usb: core: message: remove memset in usb_get_descriptor()

PATCH Superseded yuan linyu 2 participants 2 messages Jun 29, 2019 USB

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

yuan linyu

author
#0 lore raw

PATCH v2 1/1 usb: core: message: remove memset in usb_get_descriptor()

when below condition occur, the buf will be dirty again.

if (result > 1 && ((u8 *)buf)[1] != type) {
	result = -ENODATA;
	continue;
}

so caller should check return length which indicate buffer valid or not.

---
 drivers/usb/core/message.c | 2 --
 1 file changed, 2 deletions(-)
drivers/usb/core/message.c +0 -2
index e844bb7b5676..03425e6b3da9 100644
@@ -640,8 +640,6 @@ int usb_get_descriptor(struct usb_device *dev, unsigned char type,
 	int i;
 	int result;
 
-	memset(buf, 0, size);	/* Make sure we parse really received data */
-
 	for (i = 0; i < 3; ++i) {
 		/* retry on length 0 or error; some devices are flakey */
 		result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 6 lines · yuan linyu

when below condition occur, the buf will be dirty again.

if (result > 1 && ((u8 *)buf)[1] != type) {
	result = -ENODATA;
	continue;
}

so caller should check return length which indicate buffer valid or not.

I still fail to see what this means at all.

A changelog comment should explain what the problem is and why it is being fixed in this way.

Quoted 5 lines
---
 drivers/usb/core/message.c | 2 --
 1 file changed, 2 deletions(-)

Also you need to put what changed from a previous patch below the --- line like the documentation states to do.

thanks,

greg k-h