dma: mmp_pdma: fix a memory alloc error
PATCH v2 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 (*pdev->phy),GFP_KERNEL );if (pdev->phy ==NULL )return -ENOMEM ;
Signature · 1 line
1.7.5.4
Hi,
Do you have any comments about this patch? Have modified according to Vinod's advice. Thanks!
2013/6/18 Xiang Wang <[email protected]>:
Quoted 27 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 +1
-2@@ -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 (*pdev->phy),GFP_KERNEL );if (pdev->phy ==NULL )return -ENOMEM ; --1.7.5.4
Signature · 2 lines
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 (*pdev->phy),GFP_KERNEL );
While at it, can you make the flag GFP_NOWAIT. that is the recommendation for dmac drivers
--
~Vinod
2013/7/5 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 8 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 (*pdev->phy),GFP_KERNEL );While at it, can you make the flag
GFP_NOWAIT. that is the recommendation for dmac drivers--
~Vinod
Hi, Vinod
Would you please explain a little more about why we should use GFP_NOWAIT here? This memory is not dedicated for DMA controller. Do we have special reasons to use GFP_NOWAIT? Thanks!
Signature · 2 lines
Regards, Xiang
On Thu, Jul 25, 2013 at 10:22:50AM +0800, Xiang Wang wrote:
Btw its generally a good idea to remove the parts not required for further discussion
Quoted 3 lines
Would you please explain a little more about why we should use
GFP_NOWAIThere? This memory is not dedicated for DMA controller. Do we have special reasons to useGFP_NOWAIT? Thanks!
There are few reasons
- the dma requests can be triggered from atomic context
- so for above you can argue to use the GFP_ATOMIC and the guideline for dma drivers [1] was discussed briefly
~Vinod
[1]: http://lkml.indiana.edu/hypermail/linux/kernel/0911.1/02316.html
2013/7/29 Vinod Koul <[email protected]>:
Quoted 13 lines · Xiang Wang
Btw its generally a good idea to remove the parts not required for further discussion
Quoted 3 lines
Would you please explain a little more about why we should use
GFP_NOWAIThere? This memory is not dedicated for DMA controller. Do we have special reasons to useGFP_NOWAIT? Thanks!There are few reasons
- the dma requests can be triggered from atomic context
- so for above you can argue to use theGFP_ATOMICand the guideline for dma drivers [1] was discussed briefly
Quoted 4 lines
~Vinod
[1]: http://lkml.indiana.edu/hypermail/linux/kernel/0911.1/02316.html--
Hi, Vinod
Thanks for your explanation. But want to double confirm with you that the memory alloc in my patch is in probe function, still need to use GFP_NOWAIT? Thanks!
Signature · 2 lines
Regards, Xiang
Quoted 14 lines · Xiang Wang
2013/7/29 Vinod Koul <[email protected]>:
Quoted 13 lines · Xiang Wang
Btw its generally a good idea to remove the parts not required for further discussion
Quoted 3 lines
Would you please explain a little more about why we should use
GFP_NOWAIThere? This memory is not dedicated for DMA controller. Do we have special reasons to useGFP_NOWAIT? Thanks!There are few reasons
- the dma requests can be triggered from atomic context
- so for above you can argue to use theGFP_ATOMICand the guideline for dma drivers [1] was discussed briefly
Quoted 8 lines
Quoted 4 lines
~Vinod
[1]: http://lkml.indiana.edu/hypermail/linux/kernel/0911.1/02316.html--
Hi, Vinod
Thanks for your explanation. But want to double confirm with you that the memory alloc in my patch is in probe function, still need to useGFP_NOWAIT? Thanks!
Yes I would recommend it
~Vinod