* [PATCH] dmaengine: at_hdmac: do exception handling appropriately in at_dma_xlate()
@ 2020-07-29 12:29 Yu Kuai
2020-08-17 5:16 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Yu Kuai @ 2020-07-29 12:29 UTC (permalink / raw)
To: ludovic.desroches, tudor.ambarus, vkoul, dan.j.williams, arnd,
nicolas.ferre, plagnioj
Cc: linux-arm-kernel, dmaengine, linux-kernel, yi.zhang, yukuai3
Do several things for exception handing:
a. check return value of of_find_device_by_node().
b. call put_device() if memory allocation for 'atslave' failed.
c. if dma_request_channel() failed, call put_device() and kfree().
Fixes: bbe89c8e3d59 ("at_hdmac: move to generic DMA binding")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/dma/at_hdmac.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 45bbcd6146fd..a2cf25c6e3b3 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -1650,13 +1650,17 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
return NULL;
dmac_pdev = of_find_device_by_node(dma_spec->np);
+ if (!dmac_pdev)
+ return NULL;
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
atslave = kmalloc(sizeof(*atslave), GFP_KERNEL);
- if (!atslave)
+ if (!atslave) {
+ put_device(&dmac_pdev->dev);
return NULL;
+ }
atslave->cfg = ATC_DST_H2SEL_HW | ATC_SRC_H2SEL_HW;
/*
@@ -1685,8 +1689,11 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
atslave->dma_dev = &dmac_pdev->dev;
chan = dma_request_channel(mask, at_dma_filter, atslave);
- if (!chan)
+ if (!chan) {
+ put_device(&dmac_pdev->dev);
+ kfree(atslave);
return NULL;
+ }
atchan = to_at_dma_chan(chan);
atchan->per_if = dma_spec->args[0] & 0xff;
--
2.25.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dmaengine: at_hdmac: do exception handling appropriately in at_dma_xlate()
2020-07-29 12:29 [PATCH] dmaengine: at_hdmac: do exception handling appropriately in at_dma_xlate() Yu Kuai
@ 2020-08-17 5:16 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2020-08-17 5:16 UTC (permalink / raw)
To: Yu Kuai
Cc: ludovic.desroches, tudor.ambarus, dan.j.williams, arnd,
nicolas.ferre, plagnioj, linux-arm-kernel, dmaengine,
linux-kernel, yi.zhang
On 29-07-20, 20:29, Yu Kuai wrote:
> Do several things for exception handing:
>
> a. check return value of of_find_device_by_node().
> b. call put_device() if memory allocation for 'atslave' failed.
> c. if dma_request_channel() failed, call put_device() and kfree().
One patch per change please
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-17 5:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29 12:29 [PATCH] dmaengine: at_hdmac: do exception handling appropriately in at_dma_xlate() Yu Kuai
2020-08-17 5:16 ` Vinod Koul
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).