i2c: brcmstb: allocate correct amount of memory for regmap
Subsystems (3)
PATCH 1/1 i2c: brcmstb: allocate correct amount of memory for regmap
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.
--- drivers/i2c/busses/i2c-brcmstb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/i2c/busses/i2c-brcmstb.c +1 -2
@@ -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 ;
Signature · 1 line
2.7.0
PATCH 1/1 i2c: brcmstb: allocate correct amount of memory for regmap
Quoted 2 lines · Wolfram Sang
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?
Quoted 2 lines
Signed-off-by Wolfram Sang <[email protected]>
PATCH 1/1 i2c: brcmstb: allocate correct amount of memory for regmap
Quoted 7 lines · Gregory Fong
Quoted 2 lines · Wolfram Sang
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.
Quoted 2 lines
Quoted 1 line
Signed-off-by Wolfram Sang <[email protected]>Acked-by Gregory Fong <[email protected]>
Thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160222/544259df/attachment.sig>
PATCH 1/1 i2c: brcmstb: allocate correct amount of memory for regmap
In reply to Wolfram SangLe 21/02/2016 06:16, Wolfram Sang a ?crit :
Quoted 4 lines
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 <[email protected]>
controller driver")
Thanks!
Signature · 1 line
Florian
Kamal Dasu
maintainerPATCH 1/1 i2c: brcmstb: allocate correct amount of memory for regmap
Quoted 2 lines
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.
Quoted 2 lines
Signed-off-by Wolfram Sang <[email protected]>
Kamal
Wolfram Sang
AppliedPATCH 1/1 i2c: brcmstb: allocate correct amount of memory for regmap
In reply to Wolfram SangQuoted 4 lines · Wolfram Sang
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 <[email protected]>
Applied to for-current with stable tag added, thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160301/27b2c0c2/attachment-0001.sig>