lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 9 Nov 2012 08:45:03 -0800
From:	Dmitry Torokhov <dmitry.torokhov@...il.com>
To:	Viresh Kumar <viresh.kumar@...aro.org>
Cc:	linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
	spear-devel@...t.st.com
Subject: Re: [PATCH 1/3] input: stmpe-keyboard: Use devm_*() routines

Hi Viresh,

On Fri, Nov 09, 2012 at 08:57:48PM +0530, Viresh Kumar wrote:
> This patch frees stmpe-keyboard driver from tension of freeing resources :)
> devm_* derivatives of multiple routines are used while allocating resources,
> which would be freed automatically by kernel.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@...aro.org>
> ---
>  drivers/input/keyboard/stmpe-keypad.c | 31 ++++++++++---------------------
>  1 file changed, 10 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
> index 470a877..6e25497 100644
> --- a/drivers/input/keyboard/stmpe-keypad.c
> +++ b/drivers/input/keyboard/stmpe-keypad.c
> @@ -275,15 +275,14 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
>  	if (irq < 0)
>  		return irq;
>  
> -	keypad = kzalloc(sizeof(struct stmpe_keypad), GFP_KERNEL);
> +	keypad = devm_kzalloc(&pdev->dev, sizeof(struct stmpe_keypad),
> +			GFP_KERNEL);
>  	if (!keypad)
>  		return -ENOMEM;
>  
> -	input = input_allocate_device();
> -	if (!input) {
> -		ret = -ENOMEM;
> -		goto out_freekeypad;
> -	}
> +	input = devm_input_allocate_device(&pdev->dev);
> +	if (!input)
> +		return -ENOMEM;
>  
>  	input->name = "STMPE keypad";
>  	input->id.bustype = BUS_I2C;
> @@ -294,7 +293,7 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
>  					 STMPE_KEYPAD_MAX_COLS,
>  					 keypad->keymap, input);
>  	if (ret)
> -		goto out_freeinput;
> +		return ret;
>  
>  	input_set_capability(input, EV_MSC, MSC_SCAN);
>  	if (!plat->no_autorepeat)
> @@ -314,17 +313,17 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
>  
>  	ret = stmpe_keypad_chip_init(keypad);
>  	if (ret < 0)
> -		goto out_freeinput;
> +		return ret;
>  
>  	ret = input_register_device(input);
>  	if (ret) {
>  		dev_err(&pdev->dev,
>  			"unable to register input device: %d\n", ret);
> -		goto out_freeinput;
> +		return ret;
>  	}
>  
> -	ret = request_threaded_irq(irq, NULL, stmpe_keypad_irq, IRQF_ONESHOT,
> -				   "stmpe-keypad", keypad);
> +	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, stmpe_keypad_irq,
> +			IRQF_ONESHOT, "stmpe-keypad", keypad);
>  	if (ret) {
>  		dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
>  		goto out_unregisterinput;
> @@ -336,11 +335,6 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
>  
>  out_unregisterinput:
>  	input_unregister_device(input);

If input device was alocated with devm_* interface it does not need be
explicitly unregistered/freed.

Thanks.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ