All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: ti: add null check of devm_kasprintf in edma_probe and udma_probe
@ 2023-02-26  9:40 Kang Chen
  2023-03-14 20:01 ` Péter Ujfalusi
  0 siblings, 1 reply; 5+ messages in thread
From: Kang Chen @ 2023-02-26  9:40 UTC (permalink / raw)
  To: peter.ujfalusi; +Cc: vkoul, dmaengine, linux-kernel, Kang Chen

devm_kasprintf may fails, irq_name and uc->name might be null and wrong irq
name will be used in request.

Signed-off-by: Kang Chen <void0red@gmail.com>
---
 drivers/dma/ti/edma.c    | 8 ++++++++
 drivers/dma/ti/k3-udma.c | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c
index fa06d7e6d..85cd72b64 100644
--- a/drivers/dma/ti/edma.c
+++ b/drivers/dma/ti/edma.c
@@ -2413,6 +2413,10 @@ static int edma_probe(struct platform_device *pdev)
 	if (irq >= 0) {
 		irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_ccint",
 					  dev_name(dev));
+		if (!irq_name) {
+			ret = -ENOMEM;
+			goto err_disable_pm;
+		}
 		ret = devm_request_irq(dev, irq, dma_irq_handler, 0, irq_name,
 				       ecc);
 		if (ret) {
@@ -2429,6 +2433,10 @@ static int edma_probe(struct platform_device *pdev)
 	if (irq >= 0) {
 		irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_ccerrint",
 					  dev_name(dev));
+		if (!irq_name) {
+			ret = -ENOMEM;
+			goto err_disable_pm;
+		}
 		ret = devm_request_irq(dev, irq, dma_ccerr_handler, 0, irq_name,
 				       ecc);
 		if (ret) {
diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 7e23a6fde..692d1d25c 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -5494,6 +5494,8 @@ static int udma_probe(struct platform_device *pdev)
 		uc->config.dir = DMA_MEM_TO_MEM;
 		uc->name = devm_kasprintf(dev, GFP_KERNEL, "%s chan%d",
 					  dev_name(dev), i);
+		if (!uc->name)
+			return -ENOMEM;
 
 		vchan_init(&uc->vc, &ud->ddev);
 		/* Use custom vchan completion handling */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] dmaengine: ti: add null check of devm_kasprintf in edma_probe and udma_probe
  2023-02-26  9:40 [PATCH] dmaengine: ti: add null check of devm_kasprintf in edma_probe and udma_probe Kang Chen
@ 2023-03-14 20:01 ` Péter Ujfalusi
  2023-03-17 17:31   ` Vinod Koul
  0 siblings, 1 reply; 5+ messages in thread
From: Péter Ujfalusi @ 2023-03-14 20:01 UTC (permalink / raw)
  To: Kang Chen; +Cc: vkoul, dmaengine, linux-kernel

Hi,

On 26/02/2023 11:40, Kang Chen wrote:
> devm_kasprintf may fails, irq_name and uc->name might be null and wrong irq
> name will be used in request.

In general, I would have preferred to have separate patches for the two 
drivers to make them easier to backport if one decides.

If you decide to resend, you can add my to them:

Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>

> 
> Signed-off-by: Kang Chen <void0red@gmail.com>
> ---
>   drivers/dma/ti/edma.c    | 8 ++++++++
>   drivers/dma/ti/k3-udma.c | 2 ++
>   2 files changed, 10 insertions(+)
> 
> diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c
> index fa06d7e6d..85cd72b64 100644
> --- a/drivers/dma/ti/edma.c
> +++ b/drivers/dma/ti/edma.c
> @@ -2413,6 +2413,10 @@ static int edma_probe(struct platform_device *pdev)
>   	if (irq >= 0) {
>   		irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_ccint",
>   					  dev_name(dev));
> +		if (!irq_name) {
> +			ret = -ENOMEM;
> +			goto err_disable_pm;
> +		}
>   		ret = devm_request_irq(dev, irq, dma_irq_handler, 0, irq_name,
>   				       ecc);
>   		if (ret) {
> @@ -2429,6 +2433,10 @@ static int edma_probe(struct platform_device *pdev)
>   	if (irq >= 0) {
>   		irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_ccerrint",
>   					  dev_name(dev));
> +		if (!irq_name) {
> +			ret = -ENOMEM;
> +			goto err_disable_pm;
> +		}
>   		ret = devm_request_irq(dev, irq, dma_ccerr_handler, 0, irq_name,
>   				       ecc);
>   		if (ret) {
> diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
> index 7e23a6fde..692d1d25c 100644
> --- a/drivers/dma/ti/k3-udma.c
> +++ b/drivers/dma/ti/k3-udma.c
> @@ -5494,6 +5494,8 @@ static int udma_probe(struct platform_device *pdev)
>   		uc->config.dir = DMA_MEM_TO_MEM;
>   		uc->name = devm_kasprintf(dev, GFP_KERNEL, "%s chan%d",
>   					  dev_name(dev), i);
> +		if (!uc->name)
> +			return -ENOMEM;
>   
>   		vchan_init(&uc->vc, &ud->ddev);
>   		/* Use custom vchan completion handling */

-- 
Péter

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dmaengine: ti: add null check of devm_kasprintf in edma_probe and udma_probe
  2023-03-14 20:01 ` Péter Ujfalusi
@ 2023-03-17 17:31   ` Vinod Koul
  2023-03-18  6:22     ` [PATCH v2 1/2] dmaengine: ti: add null check of devm_kasprintf in udma_probe void0red
  0 siblings, 1 reply; 5+ messages in thread
From: Vinod Koul @ 2023-03-17 17:31 UTC (permalink / raw)
  To: Péter Ujfalusi; +Cc: Kang Chen, dmaengine, linux-kernel

On 14-03-23, 22:01, Péter Ujfalusi wrote:
> Hi,
> 
> On 26/02/2023 11:40, Kang Chen wrote:
> > devm_kasprintf may fails, irq_name and uc->name might be null and wrong irq
> > name will be used in request.
> 
> In general, I would have preferred to have separate patches for the two
> drivers to make them easier to backport if one decides.

Right these should be separate

> 
> If you decide to resend, you can add my to them:
> 
> Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
> 
> > 
> > Signed-off-by: Kang Chen <void0red@gmail.com>
> > ---
> >   drivers/dma/ti/edma.c    | 8 ++++++++
> >   drivers/dma/ti/k3-udma.c | 2 ++
> >   2 files changed, 10 insertions(+)
> > 
> > diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c
> > index fa06d7e6d..85cd72b64 100644
> > --- a/drivers/dma/ti/edma.c
> > +++ b/drivers/dma/ti/edma.c
> > @@ -2413,6 +2413,10 @@ static int edma_probe(struct platform_device *pdev)
> >   	if (irq >= 0) {
> >   		irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_ccint",
> >   					  dev_name(dev));
> > +		if (!irq_name) {
> > +			ret = -ENOMEM;
> > +			goto err_disable_pm;
> > +		}
> >   		ret = devm_request_irq(dev, irq, dma_irq_handler, 0, irq_name,
> >   				       ecc);
> >   		if (ret) {
> > @@ -2429,6 +2433,10 @@ static int edma_probe(struct platform_device *pdev)
> >   	if (irq >= 0) {
> >   		irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_ccerrint",
> >   					  dev_name(dev));
> > +		if (!irq_name) {
> > +			ret = -ENOMEM;
> > +			goto err_disable_pm;
> > +		}
> >   		ret = devm_request_irq(dev, irq, dma_ccerr_handler, 0, irq_name,
> >   				       ecc);
> >   		if (ret) {
> > diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
> > index 7e23a6fde..692d1d25c 100644
> > --- a/drivers/dma/ti/k3-udma.c
> > +++ b/drivers/dma/ti/k3-udma.c
> > @@ -5494,6 +5494,8 @@ static int udma_probe(struct platform_device *pdev)
> >   		uc->config.dir = DMA_MEM_TO_MEM;
> >   		uc->name = devm_kasprintf(dev, GFP_KERNEL, "%s chan%d",
> >   					  dev_name(dev), i);
> > +		if (!uc->name)
> > +			return -ENOMEM;
> >   		vchan_init(&uc->vc, &ud->ddev);
> >   		/* Use custom vchan completion handling */
> 
> -- 
> Péter

-- 
~Vinod

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] dmaengine: ti: add null check of devm_kasprintf in udma_probe
  2023-03-17 17:31   ` Vinod Koul
@ 2023-03-18  6:22     ` void0red
  2023-03-18  6:22       ` [PATCH v2 2/2] dmaengine: ti: add null check of devm_kasprintf in edma_probe void0red
  0 siblings, 1 reply; 5+ messages in thread
From: void0red @ 2023-03-18  6:22 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, linux-kernel, peter.ujfalusi, void0red

From: Kang Chen <void0red@gmail.com>

devm_kasprintf may fails, uc->name might be null and wrong irq
name will be used in request.

Fixes: 25dcb5dd7b7c ("dmaengine: ti: New driver for K3 UDMA")
Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Reviewed-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Kang Chen <void0red@gmail.com>
---
v2 -> v1: split into two patches and add some tags

 drivers/dma/ti/k3-udma.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 7e23a6fdef95..692d1d25c70a 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -5494,6 +5494,8 @@ static int udma_probe(struct platform_device *pdev)
 		uc->config.dir = DMA_MEM_TO_MEM;
 		uc->name = devm_kasprintf(dev, GFP_KERNEL, "%s chan%d",
 					  dev_name(dev), i);
+		if (!uc->name)
+			return -ENOMEM;
 
 		vchan_init(&uc->vc, &ud->ddev);
 		/* Use custom vchan completion handling */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] dmaengine: ti: add null check of devm_kasprintf in edma_probe
  2023-03-18  6:22     ` [PATCH v2 1/2] dmaengine: ti: add null check of devm_kasprintf in udma_probe void0red
@ 2023-03-18  6:22       ` void0red
  0 siblings, 0 replies; 5+ messages in thread
From: void0red @ 2023-03-18  6:22 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, linux-kernel, peter.ujfalusi, void0red

From: Kang Chen <void0red@gmail.com>

devm_kasprintf may fails, irq_name might be null and wrong irq
name will be used in request.

Fixes: 2b6b3b742019 ("ARM/dmaengine: edma: Merge the two drivers under drivers/dma/")
Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Reviewed-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Kang Chen <void0red@gmail.com>
---
v2 -> v1: split into two patches and add some tags

 drivers/dma/ti/edma.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c
index fa06d7e6d8e3..85cd72b6401a 100644
--- a/drivers/dma/ti/edma.c
+++ b/drivers/dma/ti/edma.c
@@ -2413,6 +2413,10 @@ static int edma_probe(struct platform_device *pdev)
 	if (irq >= 0) {
 		irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_ccint",
 					  dev_name(dev));
+		if (!irq_name) {
+			ret = -ENOMEM;
+			goto err_disable_pm;
+		}
 		ret = devm_request_irq(dev, irq, dma_irq_handler, 0, irq_name,
 				       ecc);
 		if (ret) {
@@ -2429,6 +2433,10 @@ static int edma_probe(struct platform_device *pdev)
 	if (irq >= 0) {
 		irq_name = devm_kasprintf(dev, GFP_KERNEL, "%s_ccerrint",
 					  dev_name(dev));
+		if (!irq_name) {
+			ret = -ENOMEM;
+			goto err_disable_pm;
+		}
 		ret = devm_request_irq(dev, irq, dma_ccerr_handler, 0, irq_name,
 				       ecc);
 		if (ret) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-18  6:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-26  9:40 [PATCH] dmaengine: ti: add null check of devm_kasprintf in edma_probe and udma_probe Kang Chen
2023-03-14 20:01 ` Péter Ujfalusi
2023-03-17 17:31   ` Vinod Koul
2023-03-18  6:22     ` [PATCH v2 1/2] dmaengine: ti: add null check of devm_kasprintf in udma_probe void0red
2023-03-18  6:22       ` [PATCH v2 2/2] dmaengine: ti: add null check of devm_kasprintf in edma_probe void0red

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.