From: Sam Bishop Date: Fri, 23 Dec 2005 00:11:02 +0000 (-0700) Subject: [PATCH] USB: fix usb-skeleton limit resource usage patch. X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=c8dd7709c534ab0d713aa698c99132b6c812b57c;p=linux-beck.git [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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index b6652ef56830..5d02f16b7d0e 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -166,7 +166,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou int retval = 0; struct urb *urb = NULL; char *buf = NULL; - size_t writesize = min(count, MAX_TRANSFER); + size_t writesize = min(count, (size_t)MAX_TRANSFER); dev = (struct usb_skel *)file->private_data; @@ -175,7 +175,10 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou goto exit; /* limit the number of URBs in flight to stop a user from using up all RAM */ - down (&dev->limit_sem); + if (down_interruptible(&dev->limit_sem)) { + retval = -ERESTARTSYS; + goto exit; + } /* create a urb, and a buffer for it, and copy the data to the urb */ urb = usb_alloc_urb(0, GFP_KERNEL);