* [PATCH v2] usb: core: message: remove memset in usb_get_descriptor()
@ 2019-06-29 8:40 yuan linyu
2019-06-29 9:13 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: yuan linyu @ 2019-06-29 8:40 UTC (permalink / raw)
To: linux-usb; +Cc: 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.
Signed-off-by: yuan linyu <cugyly@163.com>
---
drivers/usb/core/message.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index e844bb7b5676..03425e6b3da9 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -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),
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] usb: core: message: remove memset in usb_get_descriptor()
2019-06-29 8:40 [PATCH v2] usb: core: message: remove memset in usb_get_descriptor() yuan linyu
@ 2019-06-29 9:13 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2019-06-29 9:13 UTC (permalink / raw)
To: yuan linyu; +Cc: linux-usb
On Sat, Jun 29, 2019 at 04:40:11PM +0800, yuan linyu wrote:
> 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.
>
> Signed-off-by: yuan linyu <cugyly@163.com>
> ---
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-29 9:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-29 8:40 [PATCH v2] usb: core: message: remove memset in usb_get_descriptor() yuan linyu
2019-06-29 9:13 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).