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]
Message-ID: <1341506570.2605.6.camel@lorien2>
Date:	Thu, 05 Jul 2012 10:42:50 -0600
From:	Shuah Khan <shuahkhan@...il.com>
To:	Bryan Wu <bryan.wu@...onical.com>
Cc:	shuahkhan@...il.com, linux-leds@...r.kernel.org, rpurdie@...ys.net,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 21/25] leds: convert transient LED trigger driver to
 devm_kzalloc()

On Wed, 2012-07-04 at 13:10 +0800, Bryan Wu wrote:
> Cc: Shuah Khan <shuahkhan@...il.com>
> Signed-off-by: Bryan Wu <bryan.wu@...onical.com>
> ---
>  drivers/leds/ledtrig-transient.c |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/leds/ledtrig-transient.c b/drivers/leds/ledtrig-transient.c
> index 398f104..8e30b0df 100644
> --- a/drivers/leds/ledtrig-transient.c
> +++ b/drivers/leds/ledtrig-transient.c
> @@ -161,7 +161,8 @@ static void transient_trig_activate(struct led_classdev *led_cdev)
>  	int rc;
>  	struct transient_trig_data *tdata;
>  
> -	tdata = kzalloc(sizeof(struct transient_trig_data), GFP_KERNEL);
> +	tdata = devm_kzalloc(led_cdev->dev,
> +		sizeof(struct transient_trig_data), GFP_KERNEL);
>  	if (!tdata) {
>  		dev_err(led_cdev->dev,
>  			"unable to allocate transient trigger\n");
> @@ -194,7 +195,6 @@ err_out_duration:
>  err_out:
>  	dev_err(led_cdev->dev, "unable to register transient trigger\n");
>  	led_cdev->trigger_data = NULL;
> -	kfree(tdata);
>  }
>  
>  static void transient_trig_deactivate(struct led_classdev *led_cdev)
> @@ -209,7 +209,6 @@ static void transient_trig_deactivate(struct led_classdev *led_cdev)
>  		device_remove_file(led_cdev->dev, &dev_attr_state);
>  		led_cdev->trigger_data = NULL;
>  		led_cdev->activated = false;
> -		kfree(transient_data);
>  	}
>  }
>  

Bryan,

I don't believe memory triggers allocate in their activate routine
should be converted to devm_kzalloc(). Based on my understanding, the
memory allocated using devm_kzalloc() us free'ed when driver is
detached. In the case of led triggers, driver stays registered while the
triggers it supports can be activated and deactivated many times. By
converting these allocations into devm_kzalloc()s could lead to memory
leaks. Please correct me if my understanding is incorrect.

If what I am saying makes sense, please take this as comment that is
appicable to all led triggers, not just this one.

Thanks,
-- Shuah




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