public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <shuahkhan@gmail.com>
To: Fabio Baltieri <fabio.baltieri@gmail.com>
Cc: shuahkhan@gmail.com, Bryan Wu <bryan.wu@canonical.com>,
	linux-leds@vger.kernel.org, rpurdie@rpsys.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 25/25] leds: convert One-shot LED trigger driver to devm_kzalloc() and cleanup error exit path
Date: Thu, 05 Jul 2012 14:35:28 -0600	[thread overview]
Message-ID: <1341520528.3076.3.camel@lorien2> (raw)
In-Reply-To: <20120705194828.GA1563@gmail.com>

On Thu, 2012-07-05 at 21:48 +0200, Fabio Baltieri wrote:

> > >  
> > 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.
> 
> Shuah,
> 
> I'm as the same opinion - as triggers are not really "driver", in the
> sense that they are not using the driver structures, using devm_
> functions doesn't seems to be really appropriate.
> 

Correct. Each driver could support multiple triggers and triggers are
not at the same level as the device.

> Specifically:
> 
> > > +	oneshot_data = devm_kzalloc(led_cdev->dev, sizeof(*oneshot_data),
> > > +				GFP_KERNEL);
> 
> this one is registering the data on the relative LED's resources, so
> that they are not freed until you unload the LED's driver itself.
> I also think that this leads to memory leak if you keep activating
> triggers, as the deactivate function is not actually freeing the
> resources, so in that case the correct procedure should be the usual
> kalloc/kfree.
> 
> Is this consistent with what your conclusions, Shuah?

Correct. Using devm_ in triggers is not the correct and there is no need
to change from using kalloc()/kfree().

-- Shuah
> 
> Fabio
> 
> > If what I am saying makes sense, please take this as comment that is
> > applicable to all led triggers, not just this one.
> > 
> > Thanks,
> > -- Shuah
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-leds" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> 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/
> 



  reply	other threads:[~2012-07-05 20:35 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-04  5:09 [PATCH 00/25] leds: convert all kzalloc() to devm_kzalloc() Bryan Wu
2012-07-04  5:09 ` [PATCH 01/25] leds: convert Big Networks LED driver " Bryan Wu
2012-07-04  5:09 ` [PATCH 02/25] leds: convert HTC ASIC3 LED driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-04  5:09 ` [PATCH 03/25] leds: convert Atmel PWM LED driver to devm_kzalloc() Bryan Wu
2012-07-04  5:09 ` [PATCH 04/25] leds: convert LP3944 " Bryan Wu
2012-07-04  7:34   ` Bryan Wu
2012-07-04  5:09 ` [PATCH 05/25] leds: convert DA9030/DA9034 LED driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-04  5:09 ` [PATCH 06/25] leds: convert LP5521 " Bryan Wu
2012-07-04  7:35   ` Bryan Wu
2012-07-04  5:09 ` [PATCH 07/25] leds: convert BD2802 RGB " Bryan Wu
2012-07-04  5:10 ` [PATCH 08/25] leds: convert PCA9633 LED driver to devm_kzalloc() Bryan Wu
2012-07-04  5:10 ` [PATCH 09/25] leds: convert LP5523 LED driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-04  5:10 ` [PATCH 10/25] leds: convert Renesas TPU " Bryan Wu
2012-07-04  5:10 ` [PATCH 11/25] leds: convert LT3593 LED driver to devm_kzalloc() Bryan Wu
2012-07-04  5:10 ` [PATCH 12/25] leds: convert PCA9532 " Bryan Wu
2012-07-04  5:10 ` [PATCH 13/25] leds: convert Sun Fire LED driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-04  5:10 ` [PATCH 14/25] leds: convert PCA955x " Bryan Wu
2012-07-04  5:10 ` [PATCH 15/25] leds: convert ADP5520 " Bryan Wu
2012-07-04  7:40   ` Bryan Wu
2012-07-04  5:10 ` [PATCH 16/25] leds: convert Freescale MC13783 " Bryan Wu
2012-07-04  5:10 ` [PATCH 17/25] leds: convert TCA6507 LED driver to devm_kzalloc() Bryan Wu
2012-07-04  5:10 ` [PATCH 18/25] leds: convert LM3530 LED driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-05  0:01   ` Linus Walleij
2012-07-04  5:10 ` [PATCH 19/25] leds: convert DAC124S085 LED driver to devm_kzalloc() Bryan Wu
2012-07-04  5:10 ` [PATCH 20/25] leds: convert Network Space v2 LED driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-04  5:10 ` [PATCH 21/25] leds: convert transient LED trigger driver to devm_kzalloc() Bryan Wu
2012-07-05 16:42   ` Shuah Khan
2012-07-04  5:10 ` [PATCH 22/25] leds: convert GPIO LED trigger driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-05 16:45   ` Shuah Khan
2012-07-04  5:10 ` [PATCH 23/25] leds: convert Backlight emulation " Bryan Wu
2012-07-05 16:46   ` Shuah Khan
2012-07-04  5:10 ` [PATCH 24/25] leds: convert Heartbeat LED trigger driver to devm_kzalloc() Bryan Wu
2012-07-05 16:46   ` Shuah Khan
2012-07-04  5:10 ` [PATCH 25/25] leds: convert One-shot LED trigger driver to devm_kzalloc() and cleanup error exit path Bryan Wu
2012-07-05 16:47   ` Shuah Khan
2012-07-05 19:48     ` Fabio Baltieri
2012-07-05 20:35       ` Shuah Khan [this message]
2012-07-06  4:02         ` Bryan Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341520528.3076.3.camel@lorien2 \
    --to=shuahkhan@gmail.com \
    --cc=bryan.wu@canonical.com \
    --cc=fabio.baltieri@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox