ChangeSet 1.1608.84.19, 2004/03/10 12:21:49-08:00, oliver@neukum.org [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) drivers/usb/input/kbtab.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff -Nru a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c --- a/drivers/usb/input/kbtab.c Tue Mar 16 15:02:40 2004 +++ b/drivers/usb/input/kbtab.c Tue Mar 16 15:02:40 2004 @@ -4,6 +4,8 @@ #include #include #include +#include +#include /* * Version Information @@ -65,8 +67,8 @@ 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 @@ 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 @@ 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;