linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhang Rui <rui.zhang@intel.com>
To: Durgadoss R <durgadoss.r@intel.com>
Cc: eduardo.valentin@ti.com, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, hongbo.zhang@freescale.com,
	wni@nvidia.com
Subject: Re: [PATCHv4 1/9] Thermal: Check for validity before doing kfree
Date: Mon, 14 Oct 2013 13:14:40 +0800	[thread overview]
Message-ID: <1381727680.2034.1.camel@rzhang1-mobl4> (raw)
In-Reply-To: <1380652688-5787-2-git-send-email-durgadoss.r@intel.com>

On Wed, 2013-10-02 at 00:08 +0530, Durgadoss R wrote:
> The thermal_release function is called whenever
> any device belonging to 'thermal' class unregisters.
> This function performs kfree(cdev) without any check.
> In cases where there are more device registrations
> other than just 'thermal_zone' and 'cooling_device'
> this might accidently free memory allocated them
> silently; and cause memory errors.
> 
> This patch changes this behavior by doing
> kfree(cdev) only when the device pointer belongs
> to a real cdev i.e. cooling_device.
> 
> Signed-off-by: Durgadoss R <durgadoss.r@intel.com>

applied to thermal -next.

thanks,
rui
> ---
>  drivers/thermal/thermal_core.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 1f02e8e..8c5131d 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -1280,7 +1280,8 @@ static void thermal_release(struct device *dev)
>  		     sizeof("thermal_zone") - 1)) {
>  		tz = to_thermal_zone(dev);
>  		kfree(tz);
> -	} else {
> +	} else if(!strncmp(dev_name(dev), "cooling_device",
> +			sizeof("cooling_device") - 1)){
>  		cdev = to_cooling_device(dev);
>  		kfree(cdev);
>  	}



  reply	other threads:[~2013-10-14  5:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-01 18:37 [PATCHv4 0/9] Thermal Framework Enhancements Durgadoss R
2013-10-01 18:38 ` [PATCHv4 1/9] Thermal: Check for validity before doing kfree Durgadoss R
2013-10-14  5:14   ` Zhang Rui [this message]
2013-10-01 18:38 ` [PATCHv4 2/9] Thermal: Create sensor level APIs Durgadoss R
2013-10-14  9:26   ` Zhang Rui
2013-10-14 16:21     ` R, Durgadoss
2013-10-15  9:45       ` Zhang Rui
2013-10-01 18:38 ` [PATCHv4 3/9] Thermal: Create zone " Durgadoss R
2013-10-15 10:22   ` Zhang Rui
2013-10-15 11:00     ` R, Durgadoss
2013-10-01 18:38 ` [PATCHv4 4/9] Thermal: Add APIs to bind cdev to new zone structure Durgadoss R
2013-10-15 10:27   ` Zhang Rui
2013-10-01 18:38 ` [PATCHv4 5/9] Thermal: Add trip point sysfs nodes for sensor Durgadoss R
2013-10-15 11:03   ` Zhang Rui
2013-10-15 13:12     ` R, Durgadoss
2013-10-31  1:33       ` Srinivas Pandruvada
2013-10-31  5:25         ` R, Durgadoss
2013-10-01 18:38 ` [PATCHv4 6/9] Thermal: Create Thermal map sysfs attributes for a zone Durgadoss R
2013-10-01 18:38 ` [PATCHv4 7/9] Thermal: Add Documentation to new APIs Durgadoss R
2013-10-01 18:38 ` [PATCHv4 8/9] Thermal: Add ABI Documentation for sysfs interfaces Durgadoss R
2013-10-01 18:38 ` [PATCHv4 9/9] Thermal: Dummy driver used for testing Durgadoss R
2013-10-15 11:22 ` [PATCHv4 0/9] Thermal Framework Enhancements Zhang Rui

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=1381727680.2034.1.camel@rzhang1-mobl4 \
    --to=rui.zhang@intel.com \
    --cc=durgadoss.r@intel.com \
    --cc=eduardo.valentin@ti.com \
    --cc=hongbo.zhang@freescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=wni@nvidia.com \
    /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;
as well as URLs for NNTP newsgroup(s).