Skip to content

Commit 86ebbc1

Browse files
committed
USB: gadget: zero allocate endpoint 0 buffers
Under some conditions, USB gadget devices can show allocated buffer contents to a host. Fix this up by zero-allocating them so that any extra data will all just be zeros. Reported-by: Szymon Heidrich <[email protected]> Tested-by: Szymon Heidrich <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 153a2d7 commit 86ebbc1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/usb/gadget/composite.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2221,7 +2221,7 @@ int composite_dev_prepare(struct usb_composite_driver *composite,
22212221
if (!cdev->req)
22222222
return -ENOMEM;
22232223

2224-
cdev->req->buf = kmalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL);
2224+
cdev->req->buf = kzalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL);
22252225
if (!cdev->req->buf)
22262226
goto fail;
22272227

drivers/usb/gadget/legacy/dbgp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int dbgp_enable_ep_req(struct usb_ep *ep)
137137
goto fail_1;
138138
}
139139

140-
req->buf = kmalloc(DBGP_REQ_LEN, GFP_KERNEL);
140+
req->buf = kzalloc(DBGP_REQ_LEN, GFP_KERNEL);
141141
if (!req->buf) {
142142
err = -ENOMEM;
143143
stp = 2;

0 commit comments

Comments
 (0)