* [PATCH 0/3] dmaengine: zynqmp_dma: coverity fixes
@ 2022-05-10 7:12 Radhey Shyam Pandey
2022-05-10 7:12 ` [PATCH 1/3] dmaengine: zynqmp_dma: In struct zynqmp_dma_chan fix desc_size data type Radhey Shyam Pandey
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Radhey Shyam Pandey @ 2022-05-10 7:12 UTC (permalink / raw)
To: vkoul; +Cc: michal.simek, dmaengine, linux-kernel, git, Radhey Shyam Pandey
This patchset addresses coverity issues reported on zynqmp dma driver.
Radhey Shyam Pandey (2):
dmaengine: zynqmp_dma: In struct zynqmp_dma_chan fix desc_size data
type
dmaengine: zynqmp_dma: use pm_runtime_resume_and_get() instead of
pm_runtime_get_sync()
Shravya Kumbham (1):
dmaengine: zynqmp_dma: check dma_async_device_register return value
drivers/dma/xilinx/zynqmp_dma.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] dmaengine: zynqmp_dma: In struct zynqmp_dma_chan fix desc_size data type
2022-05-10 7:12 [PATCH 0/3] dmaengine: zynqmp_dma: coverity fixes Radhey Shyam Pandey
@ 2022-05-10 7:12 ` Radhey Shyam Pandey
2022-05-10 7:12 ` [PATCH 2/3] dmaengine: zynqmp_dma: check dma_async_device_register return value Radhey Shyam Pandey
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Radhey Shyam Pandey @ 2022-05-10 7:12 UTC (permalink / raw)
To: vkoul; +Cc: michal.simek, dmaengine, linux-kernel, git, Radhey Shyam Pandey
In zynqmp_dma_alloc/free_chan_resources functions there is a
potential overflow in the below expressions.
dma_alloc_coherent(chan->dev, (2 * chan->desc_size *
ZYNQMP_DMA_NUM_DESCS),
&chan->desc_pool_p, GFP_KERNEL);
dma_free_coherent(chan->dev,(2 * ZYNQMP_DMA_DESC_SIZE(chan) *
ZYNQMP_DMA_NUM_DESCS),
chan->desc_pool_v, chan->desc_pool_p);
The arguments desc_size and ZYNQMP_DMA_NUM_DESCS were 32 bit. Though
this overflow condition is not observed but it is a potential problem
in the case of 32-bit multiplication. Hence fix it by changing the
desc_size data type to size_t.
In addition to coverity fix it also reuse ZYNQMP_DMA_DESC_SIZE macro in
dma_alloc_coherent API argument.
Addresses-Coverity: Event overflow_before_widen.
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
---
drivers/dma/xilinx/zynqmp_dma.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
index 7aa63b652027..3ffa7f37c701 100644
--- a/drivers/dma/xilinx/zynqmp_dma.c
+++ b/drivers/dma/xilinx/zynqmp_dma.c
@@ -229,7 +229,7 @@ struct zynqmp_dma_chan {
bool is_dmacoherent;
struct tasklet_struct tasklet;
bool idle;
- u32 desc_size;
+ size_t desc_size;
bool err;
u32 bus_width;
u32 src_burst_len;
@@ -486,7 +486,8 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan)
}
chan->desc_pool_v = dma_alloc_coherent(chan->dev,
- (2 * chan->desc_size * ZYNQMP_DMA_NUM_DESCS),
+ (2 * ZYNQMP_DMA_DESC_SIZE(chan) *
+ ZYNQMP_DMA_NUM_DESCS),
&chan->desc_pool_p, GFP_KERNEL);
if (!chan->desc_pool_v)
return -ENOMEM;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] dmaengine: zynqmp_dma: check dma_async_device_register return value
2022-05-10 7:12 [PATCH 0/3] dmaengine: zynqmp_dma: coverity fixes Radhey Shyam Pandey
2022-05-10 7:12 ` [PATCH 1/3] dmaengine: zynqmp_dma: In struct zynqmp_dma_chan fix desc_size data type Radhey Shyam Pandey
@ 2022-05-10 7:12 ` Radhey Shyam Pandey
2022-05-10 7:12 ` [PATCH 3/3] dmaengine: zynqmp_dma: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync() Radhey Shyam Pandey
2022-05-16 12:58 ` [PATCH 0/3] dmaengine: zynqmp_dma: coverity fixes Vinod Koul
3 siblings, 0 replies; 5+ messages in thread
From: Radhey Shyam Pandey @ 2022-05-10 7:12 UTC (permalink / raw)
To: vkoul
Cc: michal.simek, dmaengine, linux-kernel, git, Shravya Kumbham,
Harini Katakam, Radhey Shyam Pandey
From: Shravya Kumbham <shravya.kumbham@xilinx.com>
Add condition to check the return value of dma_async_device_register
and implement its error handling.
Addresses-Coverity: Event check_return.
Signed-off-by: Shravya Kumbham <shravya.kumbham@xilinx.com>
Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
---
drivers/dma/xilinx/zynqmp_dma.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
index 3ffa7f37c701..915dbe6275d4 100644
--- a/drivers/dma/xilinx/zynqmp_dma.c
+++ b/drivers/dma/xilinx/zynqmp_dma.c
@@ -1094,7 +1094,11 @@ static int zynqmp_dma_probe(struct platform_device *pdev)
p->dst_addr_widths = BIT(zdev->chan->bus_width / 8);
p->src_addr_widths = BIT(zdev->chan->bus_width / 8);
- dma_async_device_register(&zdev->common);
+ ret = dma_async_device_register(&zdev->common);
+ if (ret) {
+ dev_err(zdev->dev, "failed to register the dma device\n");
+ goto free_chan_resources;
+ }
ret = of_dma_controller_register(pdev->dev.of_node,
of_zynqmp_dma_xlate, zdev);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] dmaengine: zynqmp_dma: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync()
2022-05-10 7:12 [PATCH 0/3] dmaengine: zynqmp_dma: coverity fixes Radhey Shyam Pandey
2022-05-10 7:12 ` [PATCH 1/3] dmaengine: zynqmp_dma: In struct zynqmp_dma_chan fix desc_size data type Radhey Shyam Pandey
2022-05-10 7:12 ` [PATCH 2/3] dmaengine: zynqmp_dma: check dma_async_device_register return value Radhey Shyam Pandey
@ 2022-05-10 7:12 ` Radhey Shyam Pandey
2022-05-16 12:58 ` [PATCH 0/3] dmaengine: zynqmp_dma: coverity fixes Vinod Koul
3 siblings, 0 replies; 5+ messages in thread
From: Radhey Shyam Pandey @ 2022-05-10 7:12 UTC (permalink / raw)
To: vkoul; +Cc: michal.simek, dmaengine, linux-kernel, git, Radhey Shyam Pandey
pm_runtime_resume_and_get() automatically handle dev->power.usage_count
decrement on errors, so prefer using it and also implement it's error
handling.
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
---
drivers/dma/xilinx/zynqmp_dma.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
index 915dbe6275d4..dc299ab36818 100644
--- a/drivers/dma/xilinx/zynqmp_dma.c
+++ b/drivers/dma/xilinx/zynqmp_dma.c
@@ -1078,7 +1078,11 @@ static int zynqmp_dma_probe(struct platform_device *pdev)
pm_runtime_set_autosuspend_delay(zdev->dev, ZDMA_PM_TIMEOUT);
pm_runtime_use_autosuspend(zdev->dev);
pm_runtime_enable(zdev->dev);
- pm_runtime_get_sync(zdev->dev);
+ ret = pm_runtime_resume_and_get(zdev->dev);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "device wakeup failed.\n");
+ pm_runtime_disable(zdev->dev);
+ }
if (!pm_runtime_enabled(zdev->dev)) {
ret = zynqmp_dma_runtime_resume(zdev->dev);
if (ret)
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] dmaengine: zynqmp_dma: coverity fixes
2022-05-10 7:12 [PATCH 0/3] dmaengine: zynqmp_dma: coverity fixes Radhey Shyam Pandey
` (2 preceding siblings ...)
2022-05-10 7:12 ` [PATCH 3/3] dmaengine: zynqmp_dma: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync() Radhey Shyam Pandey
@ 2022-05-16 12:58 ` Vinod Koul
3 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2022-05-16 12:58 UTC (permalink / raw)
To: Radhey Shyam Pandey; +Cc: michal.simek, dmaengine, linux-kernel, git
On 10-05-22, 12:42, Radhey Shyam Pandey wrote:
> This patchset addresses coverity issues reported on zynqmp dma driver.
>
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-05-16 12:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 7:12 [PATCH 0/3] dmaengine: zynqmp_dma: coverity fixes Radhey Shyam Pandey
2022-05-10 7:12 ` [PATCH 1/3] dmaengine: zynqmp_dma: In struct zynqmp_dma_chan fix desc_size data type Radhey Shyam Pandey
2022-05-10 7:12 ` [PATCH 2/3] dmaengine: zynqmp_dma: check dma_async_device_register return value Radhey Shyam Pandey
2022-05-10 7:12 ` [PATCH 3/3] dmaengine: zynqmp_dma: use pm_runtime_resume_and_get() instead of pm_runtime_get_sync() Radhey Shyam Pandey
2022-05-16 12:58 ` [PATCH 0/3] dmaengine: zynqmp_dma: coverity fixes 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).