lkml.org 
[lkml]   [2006]   [Jan]   [7]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
FromDmitry Torokhov <>
SubjectRe: dynamic input_dev allocation for ibmasm driver
DateSat, 7 Jan 2006 00:01:32 -0500
On Friday 06 January 2006 18:59, Vernon Mauery wrote:
> This patch updates the ibmasm driver to use the dynamic allocation of input_dev
> structs to work with the sysfs subsystem.  I have tested it on my machine and it
> seems to work fine.
> 
> Signed-off-by: Vernon Mauery <vernux@us.ibm.com>
> 
>  ibmasm.h |    6 ++---
>  remote.c |   72 ++++++++++++++++++++++++++++++++++-----------------------------
>  2 files changed, 42 insertions(+), 36 deletions(-)
> 
> 
...
> -	input_register_device(&remote->mouse_dev);
> -	input_register_device(&remote->keybd_dev);
> +	if ((ret = input_register_device(mouse_dev)))
> +		goto error_alloc;
> +	if ((ret = input_register_device(keybd_dev)))
> +		goto error_alloc;
> +
> +	sp->remote.mouse_dev = mouse_dev;
> +	sp->remote.keybd_dev = keybd_dev;
>  	enable_mouse_interrupts(sp);
> 
>  	printk(KERN_INFO "ibmasm remote responding to events on RSA card %d\n", sp->number);
> 
>  	return 0;
> +
> +error_alloc:
> +	input_free_device(mouse_dev);
> +	input_free_device(keybd_dev);
> +	return ret;

Error handling is rotten here. If 2nd input_register_device fails you will
whack fully registered remote->mouse_dev. You are missing call to
input_unregister_device() there.

Please fix it up and send it my way - I'll add it to the input tree.

Thanks!

-- 
Dmitry
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-01-07 06:04    [from the cache]
©2003-2008