Commit ddd3d78b authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

[PATCH] USB: bug in error code path of kbtab driver

this fixes
- a leak in the error code path of open()
- removes SLAB_ATOMIC where it isn't needed
- uses le16_to_cpu (yes Pete, unaligned access is taken care of)
parent f3f3a0ab
......@@ -4,6 +4,8 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/usb.h>
#include <asm/unaligned.h>
#include <asm/byteorder.h>
/*
* Version Information
......@@ -65,8 +67,8 @@ static void kbtab_irq(struct urb *urb, struct pt_regs *regs)
goto exit;
}
kbtab->x = (data[2] << 8) + data[1];
kbtab->y = (data[4] << 8) + data[3];
kbtab->x = le16_to_cpu(get_unaligned((u16 *) &data[1]));
kbtab->y = le16_to_cpu(get_unaligned((u16 *) &data[3]));
kbtab->pressure = (data[5]);
......@@ -108,8 +110,10 @@ static int kbtab_open(struct input_dev *dev)
return 0;
kbtab->irq->dev = kbtab->usbdev;
if (usb_submit_urb(kbtab->irq, GFP_KERNEL))
if (usb_submit_urb(kbtab->irq, GFP_KERNEL)) {
kbtab->open--;
return -EIO;
}
return 0;
}
......@@ -133,7 +137,7 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
return -ENOMEM;
memset(kbtab, 0, sizeof(struct kbtab));
kbtab->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &kbtab->data_dma);
kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma);
if (!kbtab->data) {
kfree(kbtab);
return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment