dma: mmp_pdma: fix a memory alloc error
PATCH 1/1 dma: mmp_pdma: fix a memory alloc error
From: Xiang Wang <[email protected]>
pdev->phy is of type "struct mmp_pdma_phy *". But when allocating memory for it, "struct mmp_pdma_chan" is used by mistake.
--- drivers/dma/mmp_pdma.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/dma/mmp_pdma.c +1 -1
@@ -801,7 +801,7 @@ static int mmp_pdma_probe(struct platform_device *op) } pdev->phy =devm_kzalloc (pdev->dev, - dma_channels *sizeof (struct mmp_pdma_chan ),GFP_KERNEL ); + dma_channels *sizeof (struct mmp_pdma_phy ),GFP_KERNEL );if (pdev->phy ==NULL )return -ENOMEM ;
Signature · 1 line
1.7.5.4
Quoted 5 lines · Xiang Wang
From: Xiang Wang <[email protected]>
pdev->phyis of type "structmmp_pdma_phy*". But when allocating memory for it, "structmmp_pdma_chan" is used by mistake.
Have you tested it?
Quoted 10 lines
Signed-off-by Xiang Wang <[email protected]>--- drivers/dma/mmp_pdma.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/dma/mmp_pdma.c +0
-0
drivers/dma/mmp_pdma.c static int mmp_pdma_probe(struct platform_device *op) · line 804
Quoted 5 lines
drivers/dma/mmp_pdma.c +1
-1@@ -801,7 +801,7 @@ static int mmp_pdma_probe(struct platform_device *op) } pdev->phy =devm_kzalloc (pdev->dev, - dma_channels *sizeof (struct mmp_pdma_chan ),GFP_KERNEL ); + dma_channels *sizeof (struct mmp_pdma_phy ),GFP_KERNEL );
For me it seems you did get how it works.
--
With Best Regards,
Andy Shevchenko
2013/5/28 Andy Shevchenko <[email protected]>:
Quoted 27 lines · Xiang Wang
Quoted 5 lines
From: Xiang Wang <[email protected]>
pdev->phyis of type "structmmp_pdma_phy*". But when allocating memory for it, "structmmp_pdma_chan" is used by mistake.Have you tested it?
Quoted 10 lines
Signed-off-by Xiang Wang <[email protected]>--- drivers/dma/mmp_pdma.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/dma/mmp_pdma.c +0
-0drivers/dma/mmp_pdma.c static int mmp_pdma_probe(struct platform_device *op) · line 804
Quoted 5 lines
drivers/dma/mmp_pdma.c +1
-1@@ -801,7 +801,7 @@ static int mmp_pdma_probe(struct platform_device *op) } pdev->phy =devm_kzalloc (pdev->dev, - dma_channels *sizeof (struct mmp_pdma_chan ),GFP_KERNEL ); + dma_channels *sizeof (struct mmp_pdma_phy ),GFP_KERNEL );For me it seems you did get how it works.
Quoted 3 lines
--
With Best Regards,
Andy Shevchenko
Hi, Andy
Yes. I've tested on marvell pxa988 platform using dmatest.ko.
2013/5/31 Xiang Wang <[email protected]>:
Quoted 28 lines
2013/5/28 Andy Shevchenko <[email protected]>:
Quoted 27 lines · Xiang Wang
Quoted 5 lines
From: Xiang Wang <[email protected]>
pdev->phyis of type "structmmp_pdma_phy*". But when allocating memory for it, "structmmp_pdma_chan" is used by mistake.Have you tested it?
Quoted 10 lines
Signed-off-by Xiang Wang <[email protected]>--- drivers/dma/mmp_pdma.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/dma/mmp_pdma.c +0
-0drivers/dma/mmp_pdma.c static int mmp_pdma_probe(struct platform_device *op) · line 804
Quoted 5 lines
drivers/dma/mmp_pdma.c +1
-1@@ -801,7 +801,7 @@ static int mmp_pdma_probe(struct platform_device *op) } pdev->phy =devm_kzalloc (pdev->dev, - dma_channels *sizeof (struct mmp_pdma_chan ),GFP_KERNEL ); + dma_channels *sizeof (struct mmp_pdma_phy ),GFP_KERNEL );For me it seems you did get how it works.
Quoted 6 lines
Quoted 3 lines
--
With Best Regards,
Andy ShevchenkoHi, Andy
Yes. I've tested on marvell pxa988 platform using dmatest.ko.
Hi, All
Do you have any comments about this patch? Thanks!
--
Regards,
Xiang
Quoted 16 lines · Xiang Wang
From: Xiang Wang <[email protected]>
pdev->phyis of type "structmmp_pdma_phy*". But when allocating memory for it, "structmmp_pdma_chan" is used by mistake.Signed-off-by Xiang Wang <[email protected]>--- drivers/dma/mmp_pdma.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/dma/mmp_pdma.c +0
-0
drivers/dma/mmp_pdma.c static int mmp_pdma_probe(struct platform_device *op) · line 804
Quoted 5 lines
drivers/dma/mmp_pdma.c +1
-1@@ -801,7 +801,7 @@ static int mmp_pdma_probe(struct platform_device *op) } pdev->phy =devm_kzalloc (pdev->dev, - dma_channels *sizeof (struct mmp_pdma_chan ),GFP_KERNEL ); + dma_channels *sizeof (struct mmp_pdma_phy ),GFP_KERNEL );
why not sizeof(*pdev-phy), that way you dont make above error
--
~Vinod
2013/6/17 Vinod Koul <[email protected]>:
Quoted 19 lines · Xiang Wang
Quoted 18 lines
From: Xiang Wang <[email protected]>
pdev->phyis of type "structmmp_pdma_phy*". But when allocating memory for it, "structmmp_pdma_chan" is used by mistake.Signed-off-by Xiang Wang <[email protected]>--- drivers/dma/mmp_pdma.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/dma/mmp_pdma.c +0
-0@@ -801,7 +801,7 @@ static int mmp_pdma_probe(struct platform_device *op) }
Quoted 7 lines
drivers/dma/mmp_pdma.c static int mmp_pdma_probe(struct platform_device *op) · line 804
Quoted 3 lines
drivers/dma/mmp_pdma.c +1
-1pdev->phy =devm_kzalloc (pdev->dev, - dma_channels *sizeof (struct mmp_pdma_chan ),GFP_KERNEL ); + dma_channels *sizeof (struct mmp_pdma_phy ),GFP_KERNEL );why not
sizeof(*pdev-phy), that way you dont make above error--
~Vinod
Hi,
Updated patch V2 to use sizeof(*pdev->phy). Thanks!
--
Regards,
Xiang