Re: [patch]fix memleak in error case of hiddev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 31 Oct 2008, Oliver Neukum wrote:

> this bug is old, the patch should go into 2.6.28 and stable.
> This fixes a memleak in hiddev's open in an error case.
> ---
> 
> diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
> index b218cbc..6834d1f 100644
> --- a/drivers/hid/usbhid/hiddev.c
> +++ b/drivers/hid/usbhid/hiddev.c
> @@ -291,8 +291,13 @@ static int hiddev_open(struct inode *inode, struct file *file)
>  		if (list->hiddev->exist) {
>  			struct hid_device *hid = hiddev_table[i]->hid;
>  			res = usbhid_get_power(hid);
> -			if (res < 0)
> +			if (res < 0) {
> +				spin_lock_irqsave(&list->hiddev->list_lock, flags);
> +				list_del(&list->node);
> +				spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
> +				kfree(list->hiddev);
>  				return -EIO;
> +			}
>  			usbhid_open(hid);
>  		}

Hmm, this is probably based on not-yet-merged usbhid autosuspend patchset, 
right?

Now, you are right that hiddev_open() doesn't handle error condition from 
usbhid_open(), and that should be fixed. But that doesn't seem to be 
addressed by your patch at all ... ?

Thanks,

-- 
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux