All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhang Rui <rui.zhang@intel.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>,
	Pi-Hsun Shih <pihsun@chromium.org>
Cc: Eduardo Valentin <edubezval@gmail.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	"open list:THERMAL" <linux-pm@vger.kernel.org>,
	"moderated list:ARM/Mediatek SoC support" 
	<linux-arm-kernel@lists.infradead.org>,
	"moderated list:ARM/Mediatek SoC support" 
	<linux-mediatek@lists.infradead.org>,
	open list <linux-kernel@vger.kernel.org>,
	Michael.Kao@mediatek.com
Subject: Re: [PATCH] thermal: mtk: Allocate enough space for mtk_thermal.
Date: Wed, 30 Jan 2019 21:38:40 +0800	[thread overview]
Message-ID: <1548855520.2161.3.camel@intel.com> (raw)
In-Reply-To: <49dbd0af-975e-cafb-d1b9-4e491a6c9383@linaro.org>

On 三, 2019-01-30 at 11:04 +0100, Daniel Lezcano wrote:
> On 30/01/2019 10:25, Pi-Hsun Shih wrote:
> > 
> > On Wed, Jan 30, 2019 at 3:44 PM Daniel Lezcano
> > <daniel.lezcano@linaro.org> wrote:
> > > 
> > > 
> > > On 30/01/2019 07:04, Peter Shih wrote:
> > > > 
> > > > Adding Michael Kao to cc list.
> > > > 
> > > > On Wed, Jan 9, 2019 at 1:57 PM Pi-Hsun Shih <pihsun@chromium.or
> > > > g> wrote:
> > > > > 
> > > > > 
> > > > > The mtk_thermal struct contains a 'struct mtk_thermal_bank
> > > > > banks[];',
> > > > > but the allocation only allocates sizeof(struct mtk_thermal)
> > > > > bytes,
> > > > > which cause out of bound access with the ->banks[] member.
> > > > > Change it to
> > > > > a fixed size array instead.
> > > Even if the fix is correct, it pushes back the bug later in time
> > > if a
> > > new board containing more than MAX_NUM_ZONES is introduced. I
> > > suggest to
> > > dynamically allocate the array with the 'num_banks' value.
> > > 
> > For the current code structure, those mtk_thermal_data are
> > statically declared,
> > so if there's new board containing more than MAX_NUM_ZONES of
> > bank_data, it
> > would actually be a compile error.
> > 
> > I'm fine with either way, but feel like that this is simpler than
> > manually
> > calculating the size needed for allocation.
> Right, I missed it can be caught at compile time.
> 
> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> 
As this is a bugfix, I will take it and queue it for next -rc.

thanks,
rui
> 
> 

WARNING: multiple messages have this Message-ID (diff)
From: Zhang Rui <rui.zhang@intel.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>,
	Pi-Hsun Shih <pihsun@chromium.org>
Cc: "open list:THERMAL" <linux-pm@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	Michael.Kao@mediatek.com, Eduardo Valentin <edubezval@gmail.com>,
	"moderated list:ARM/Mediatek SoC support"
	<linux-mediatek@lists.infradead.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	"moderated list:ARM/Mediatek SoC support"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] thermal: mtk: Allocate enough space for mtk_thermal.
Date: Wed, 30 Jan 2019 21:38:40 +0800	[thread overview]
Message-ID: <1548855520.2161.3.camel@intel.com> (raw)
In-Reply-To: <49dbd0af-975e-cafb-d1b9-4e491a6c9383@linaro.org>

On 三, 2019-01-30 at 11:04 +0100, Daniel Lezcano wrote:
> On 30/01/2019 10:25, Pi-Hsun Shih wrote:
> > 
> > On Wed, Jan 30, 2019 at 3:44 PM Daniel Lezcano
> > <daniel.lezcano@linaro.org> wrote:
> > > 
> > > 
> > > On 30/01/2019 07:04, Peter Shih wrote:
> > > > 
> > > > Adding Michael Kao to cc list.
> > > > 
> > > > On Wed, Jan 9, 2019 at 1:57 PM Pi-Hsun Shih <pihsun@chromium.or
> > > > g> wrote:
> > > > > 
> > > > > 
> > > > > The mtk_thermal struct contains a 'struct mtk_thermal_bank
> > > > > banks[];',
> > > > > but the allocation only allocates sizeof(struct mtk_thermal)
> > > > > bytes,
> > > > > which cause out of bound access with the ->banks[] member.
> > > > > Change it to
> > > > > a fixed size array instead.
> > > Even if the fix is correct, it pushes back the bug later in time
> > > if a
> > > new board containing more than MAX_NUM_ZONES is introduced. I
> > > suggest to
> > > dynamically allocate the array with the 'num_banks' value.
> > > 
> > For the current code structure, those mtk_thermal_data are
> > statically declared,
> > so if there's new board containing more than MAX_NUM_ZONES of
> > bank_data, it
> > would actually be a compile error.
> > 
> > I'm fine with either way, but feel like that this is simpler than
> > manually
> > calculating the size needed for allocation.
> Right, I missed it can be caught at compile time.
> 
> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> 
As this is a bugfix, I will take it and queue it for next -rc.

thanks,
rui
> 
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-01-30 13:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09  5:57 [PATCH] thermal: mtk: Allocate enough space for mtk_thermal Pi-Hsun Shih
2019-01-09  5:57 ` Pi-Hsun Shih
2019-01-09  5:57 ` Pi-Hsun Shih
2019-01-30  6:04 ` Peter Shih
2019-01-30  6:04   ` Peter Shih
2019-01-30  6:04   ` Peter Shih
2019-01-30  7:44   ` Daniel Lezcano
2019-01-30  7:44     ` Daniel Lezcano
2019-01-30  7:44     ` Daniel Lezcano
2019-01-30  9:25     ` Pi-Hsun Shih
2019-01-30  9:25       ` Pi-Hsun Shih
2019-01-30 10:04       ` Daniel Lezcano
2019-01-30 10:04         ` Daniel Lezcano
2019-01-30 10:04         ` Daniel Lezcano
2019-01-30 13:38         ` Zhang Rui [this message]
2019-01-30 13:38           ` Zhang Rui
2019-01-30 13:38           ` Zhang Rui
2019-02-07 16:25 ` Matthias Brugger
2019-02-07 16:25   ` Matthias Brugger
2019-02-07 16:25   ` Matthias Brugger

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=1548855520.2161.3.camel@intel.com \
    --to=rui.zhang@intel.com \
    --cc=Michael.Kao@mediatek.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=edubezval@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=pihsun@chromium.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.