Commit c8dd7709c534ab0d713aa698c99132b6c812b57c

Authored by Sam Bishop
Committed by Greg Kroah-Hartman
1 parent cb5b3f6950

[PATCH] USB: fix usb-skeleton limit resource usage patch.

Prevents a compiler warning and uses down_interruptible() instead of down() in
process context.

Signed-off-by: Sam Bishop <sam@bishop.dhs.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 1 changed file with 5 additions and 2 deletions Side-by-side Diff

drivers/usb/usb-skeleton.c
... ... @@ -166,7 +166,7 @@
166 166 int retval = 0;
167 167 struct urb *urb = NULL;
168 168 char *buf = NULL;
169   - size_t writesize = min(count, MAX_TRANSFER);
  169 + size_t writesize = min(count, (size_t)MAX_TRANSFER);
170 170  
171 171 dev = (struct usb_skel *)file->private_data;
172 172  
... ... @@ -175,7 +175,10 @@
175 175 goto exit;
176 176  
177 177 /* limit the number of URBs in flight to stop a user from using up all RAM */
178   - down (&dev->limit_sem);
  178 + if (down_interruptible(&dev->limit_sem)) {
  179 + retval = -ERESTARTSYS;
  180 + goto exit;
  181 + }
179 182  
180 183 /* create a urb, and a buffer for it, and copy the data to the urb */
181 184 urb = usb_alloc_urb(0, GFP_KERNEL);