Re: [PATCH] Input: Avoid kernel panic during device unregistration

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

 



Hi Aniroop,

On Sun, Dec 28, 2014 at 11:42:05PM +0530, Aniroop Mathur wrote:
> This patch adds null check before actually unregistering the input device
> to avoid null pointer exception which leads to kernel panic.
> 
> So now, input device drivers won't have to worry about or add null case
> condition before calling input_unregister_device() in shutdown and
> remove functions.

input_unregister_device() should be called only if
input_register_device() succeeded, which it would not with input device
being NULL.

Unlike input_free_device() which does handle NULL argument, similar to
many other "free" APIs I do not believe that input_unregister_device
should be handling such cases.

> 
> Signed-off-by: Aniroop Mathur <a.mathur@xxxxxxxxxxx>
> ---
>  drivers/input/input.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 01fe49e..575219d 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -2170,6 +2170,9 @@ EXPORT_SYMBOL(input_register_device);
>   */
>  void input_unregister_device(struct input_dev *dev)
>  {
> +	if (!dev)
> +		return;
> +
>  	if (dev->devres_managed) {
>  		WARN_ON(devres_destroy(dev->dev.parent,
>  					devm_input_device_unregister,
> -- 
> 1.9.1
> 

Thanks.

-- 
Dmitry
--
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