linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap
@ 2016-02-21 14:16 Wolfram Sang
  2016-02-22  6:33 ` Gregory Fong
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Wolfram Sang @ 2016-02-21 14:16 UTC (permalink / raw)
  To: linux-i2c
  Cc: Florian Fainelli, Wolfram Sang, bcm-kernel-feedback-list,
	Gregory Fong, Brian Norris, linux-arm-kernel

We want the size of the struct, not of a pointer to it. To be future
proof, just dereference the pointer to get the desired type.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/i2c/busses/i2c-brcmstb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c
index 3711df1d452622..4a45408dd82060 100644
--- a/drivers/i2c/busses/i2c-brcmstb.c
+++ b/drivers/i2c/busses/i2c-brcmstb.c
@@ -586,8 +586,7 @@ static int brcmstb_i2c_probe(struct platform_device *pdev)
 	if (!dev)
 		return -ENOMEM;
 
-	dev->bsc_regmap = devm_kzalloc(&pdev->dev, sizeof(struct bsc_regs *),
-				       GFP_KERNEL);
+	dev->bsc_regmap = devm_kzalloc(&pdev->dev, sizeof(*dev->bsc_regmap), GFP_KERNEL);
 	if (!dev->bsc_regmap)
 		return -ENOMEM;
 
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap
  2016-02-21 14:16 [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap Wolfram Sang
@ 2016-02-22  6:33 ` Gregory Fong
  2016-02-22  8:05   ` Wolfram Sang
  2016-02-22 16:42 ` Florian Fainelli
  2016-03-01 18:19 ` Wolfram Sang
  2 siblings, 1 reply; 9+ messages in thread
From: Gregory Fong @ 2016-02-22  6:33 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c, Brian Norris, Florian Fainelli,
	linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list

On Sun, Feb 21, 2016 at 6:16 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
> We want the size of the struct, not of a pointer to it. To be future
> proof, just dereference the pointer to get the desired type.

This looks like it fixes like a fairly serious issue: before this
change, the driver may modify memory that wasn't allocated for this
struct.  Shouldn't this also have Cc: stable?

>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

Acked-by: Gregory Fong <gregory.0xf0@gmail.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap
  2016-02-22  6:33 ` Gregory Fong
@ 2016-02-22  8:05   ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2016-02-22  8:05 UTC (permalink / raw)
  To: Gregory Fong
  Cc: linux-i2c, Brian Norris, Florian Fainelli,
	linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list

[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

On Sun, Feb 21, 2016 at 10:33:14PM -0800, Gregory Fong wrote:
> On Sun, Feb 21, 2016 at 6:16 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
> > We want the size of the struct, not of a pointer to it. To be future
> > proof, just dereference the pointer to get the desired type.
> 
> This looks like it fixes like a fairly serious issue: before this
> change, the driver may modify memory that wasn't allocated for this
> struct.  Shouldn't this also have Cc: stable?

Surely. I usually add the tag when committing, not when sending out.

> > Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> Acked-by: Gregory Fong <gregory.0xf0@gmail.com>

Thanks.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap
  2016-02-21 14:16 [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap Wolfram Sang
  2016-02-22  6:33 ` Gregory Fong
@ 2016-02-22 16:42 ` Florian Fainelli
  2016-02-25 20:08   ` Kamal Dasu
  2016-03-01 18:19 ` Wolfram Sang
  2 siblings, 1 reply; 9+ messages in thread
From: Florian Fainelli @ 2016-02-22 16:42 UTC (permalink / raw)
  To: Wolfram Sang, linux-i2c
  Cc: Brian Norris, Gregory Fong, linux-arm-kernel,
	bcm-kernel-feedback-list

Le 21/02/2016 06:16, Wolfram Sang a écrit :
> We want the size of the struct, not of a pointer to it. To be future
> proof, just dereference the pointer to get the desired type.
> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

Fixes: dd1aa2524bc5 ("i2c: brcmstb: Add Broadcom settop SoC i2c
controller driver")

Acked-by: Florian Fainelli <f.fainelli@gmail.com>

Thanks!
-- 
Florian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap
@ 2016-02-25 19:32 Kamal Dasu
  2016-03-01 16:14 ` Kamal Dasu
  0 siblings, 1 reply; 9+ messages in thread
From: Kamal Dasu @ 2016-02-25 19:32 UTC (permalink / raw)
  To: linux-i2c
  Cc: Wolfram Sang, linux-arm-kernel, bcm-kernel-feedback-list.pdl,
	Brian Norris, Gregory Fong, Florian Fainelli

> We want the size of the struct, not of a pointer to it. To be future proof,
> just dereference the pointer to get the desired type.

Thanks for catching and fixing this.

>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

Reviewed-by: Kamal Dasu <kdasu.kdev@gmail.com>

Kamal

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap
  2016-02-22 16:42 ` Florian Fainelli
@ 2016-02-25 20:08   ` Kamal Dasu
  0 siblings, 0 replies; 9+ messages in thread
From: Kamal Dasu @ 2016-02-25 20:08 UTC (permalink / raw)
  To: 'Wolfram Sang', linux-i2c; +Cc: linux-arm-kernel

> We want the size of the struct, not of a pointer to it. To be future 
> proof, just dereference the pointer to get the desired type.

Thanks for catching and fixing this.

>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

Reviewed-by: Kamal Dasu <kdasu.kdev@gmail.com>

Kamal

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap
  2016-02-25 19:32 Kamal Dasu
@ 2016-03-01 16:14 ` Kamal Dasu
  2016-03-01 16:19   ` Wolfram Sang
  0 siblings, 1 reply; 9+ messages in thread
From: Kamal Dasu @ 2016-03-01 16:14 UTC (permalink / raw)
  To: linux-i2c
  Cc: Wolfram Sang, linux-arm-kernel, bcm-kernel-feedback-list.pdl,
	Brian Norris, Gregory Fong, Florian Fainelli

Wolfram,

I found a minor checkpatch issue with the change while applying the
patch to my local branch.

WARNING: line over 80 characters
#11: FILE: drivers/i2c/busses/i2c-brcmstb.c:589:
+       dev->bsc_regmap = devm_kzalloc(&pdev->dev,
sizeof(*dev->bsc_regmap), GFP_KERNEL);

Kamal

On Thu, Feb 25, 2016 at 2:32 PM, Kamal Dasu <kdasu.kdev@gmail.com> wrote:
>> We want the size of the struct, not of a pointer to it. To be future proof,
>> just dereference the pointer to get the desired type.
>
> Thanks for catching and fixing this.
>
>>
>> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
>
> Reviewed-by: Kamal Dasu <kdasu.kdev@gmail.com>
>
> Kamal

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap
  2016-03-01 16:14 ` Kamal Dasu
@ 2016-03-01 16:19   ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2016-03-01 16:19 UTC (permalink / raw)
  To: Kamal Dasu
  Cc: linux-i2c, linux-arm-kernel, bcm-kernel-feedback-list.pdl,
	Brian Norris, Gregory Fong, Florian Fainelli

[-- Attachment #1: Type: text/plain, Size: 180 bytes --]

> WARNING: line over 80 characters

I am not too strict with this one. If one is just slightly over 80 chars
and then breaks the line, readability of the code usually gets worse.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap
  2016-02-21 14:16 [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap Wolfram Sang
  2016-02-22  6:33 ` Gregory Fong
  2016-02-22 16:42 ` Florian Fainelli
@ 2016-03-01 18:19 ` Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2016-03-01 18:19 UTC (permalink / raw)
  To: linux-i2c
  Cc: Brian Norris, Gregory Fong, Florian Fainelli, linux-arm-kernel,
	bcm-kernel-feedback-list

[-- Attachment #1: Type: text/plain, Size: 313 bytes --]

On Sun, Feb 21, 2016 at 03:16:48PM +0100, Wolfram Sang wrote:
> We want the size of the struct, not of a pointer to it. To be future
> proof, just dereference the pointer to get the desired type.
> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

Applied to for-current with stable tag added, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-03-01 18:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-21 14:16 [PATCH] i2c: brcmstb: allocate correct amount of memory for regmap Wolfram Sang
2016-02-22  6:33 ` Gregory Fong
2016-02-22  8:05   ` Wolfram Sang
2016-02-22 16:42 ` Florian Fainelli
2016-02-25 20:08   ` Kamal Dasu
2016-03-01 18:19 ` Wolfram Sang
  -- strict thread matches above, loose matches on Subject: below --
2016-02-25 19:32 Kamal Dasu
2016-03-01 16:14 ` Kamal Dasu
2016-03-01 16:19   ` Wolfram Sang

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