All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] rapidio: Two fixes for 'rio_dma_transfer()'
@ 2017-09-17 22:33 ` Christophe JAILLET
  0 siblings, 0 replies; 8+ messages in thread
From: Christophe JAILLET @ 2017-09-17 22:33 UTC (permalink / raw)
  To: mporter, alexandre.bounine, lstoakes, akpm, jesper.nilsson,
	christian.koenig, logang
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

These 2 patches are really close and are both related to error handling
in 'rio_dma_transfer()'.
The first one fixes some resources leak in case of error.
The 2nd one fixes a test so that the corresponding error can be handled
correctly.

I've splitted this into 2 paches because the first one looks trivial to me.
But the 2nd one should require more attention, IMO. The existing error
handling was dead code because 'dma_map_sg()' can not return -EFAULT. So
this error handling code has never been executed/tested and I can't test it
myself.

Christophe JAILLET (2):
  rapidio: Fix resources leak in error handling path in
    'rio_dma_transfer()'
  rapidio: Fix an error handling in 'rio_dma_transfer()'

 drivers/rapidio/devices/rio_mport_cdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

-- 
2.11.0

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

* [PATCH 0/2] rapidio: Two fixes for 'rio_dma_transfer()'
@ 2017-09-17 22:33 ` Christophe JAILLET
  0 siblings, 0 replies; 8+ messages in thread
From: Christophe JAILLET @ 2017-09-17 22:33 UTC (permalink / raw)
  To: mporter, alexandre.bounine, lstoakes, akpm, jesper.nilsson,
	christian.koenig, logang
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

These 2 patches are really close and are both related to error handling
in 'rio_dma_transfer()'.
The first one fixes some resources leak in case of error.
The 2nd one fixes a test so that the corresponding error can be handled
correctly.

I've splitted this into 2 paches because the first one looks trivial to me.
But the 2nd one should require more attention, IMO. The existing error
handling was dead code because 'dma_map_sg()' can not return -EFAULT. So
this error handling code has never been executed/tested and I can't test it
myself.

Christophe JAILLET (2):
  rapidio: Fix resources leak in error handling path in
    'rio_dma_transfer()'
  rapidio: Fix an error handling in 'rio_dma_transfer()'

 drivers/rapidio/devices/rio_mport_cdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

-- 
2.11.0


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

* [PATCH 1/2] rapidio: Fix resources leak in error handling path in 'rio_dma_transfer()'
  2017-09-17 22:33 ` Christophe JAILLET
@ 2017-09-17 22:33   ` Christophe JAILLET
  -1 siblings, 0 replies; 8+ messages in thread
From: Christophe JAILLET @ 2017-09-17 22:33 UTC (permalink / raw)
  To: mporter, alexandre.bounine, lstoakes, akpm, jesper.nilsson,
	christian.koenig, logang
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

If 'dma_map_sg()', we should branch to the existing error handling path to
free some resources before returning.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/rapidio/devices/rio_mport_cdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 5beb0c361076..76afe1449cab 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -963,7 +963,8 @@ rio_dma_transfer(struct file *filp, u32 transfer_mode,
 			   req->sgt.sgl, req->sgt.nents, dir);
 	if (nents == -EFAULT) {
 		rmcd_error("Failed to map SG list");
-		return -EFAULT;
+		ret = -EFAULT;
+		goto err_pg;
 	}
 
 	ret = do_dma_request(req, xfer, sync, nents);
-- 
2.11.0

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

* [PATCH 1/2] rapidio: Fix resources leak in error handling path in 'rio_dma_transfer()'
@ 2017-09-17 22:33   ` Christophe JAILLET
  0 siblings, 0 replies; 8+ messages in thread
From: Christophe JAILLET @ 2017-09-17 22:33 UTC (permalink / raw)
  To: mporter, alexandre.bounine, lstoakes, akpm, jesper.nilsson,
	christian.koenig, logang
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

If 'dma_map_sg()', we should branch to the existing error handling path to
free some resources before returning.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/rapidio/devices/rio_mport_cdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 5beb0c361076..76afe1449cab 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -963,7 +963,8 @@ rio_dma_transfer(struct file *filp, u32 transfer_mode,
 			   req->sgt.sgl, req->sgt.nents, dir);
 	if (nents = -EFAULT) {
 		rmcd_error("Failed to map SG list");
-		return -EFAULT;
+		ret = -EFAULT;
+		goto err_pg;
 	}
 
 	ret = do_dma_request(req, xfer, sync, nents);
-- 
2.11.0


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

* [PATCH 2/2] rapidio: Fix an error handling in 'rio_dma_transfer()'
  2017-09-17 22:33 ` Christophe JAILLET
@ 2017-09-17 22:33   ` Christophe JAILLET
  -1 siblings, 0 replies; 8+ messages in thread
From: Christophe JAILLET @ 2017-09-17 22:33 UTC (permalink / raw)
  To: mporter, alexandre.bounine, lstoakes, akpm, jesper.nilsson,
	christian.koenig, logang
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

In case of error, 'dma_map_sg()' returns 0, not a negative value.
There is BUG_ON() in 'dma_map_sg_attrs()'  which makes sure of that.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/rapidio/devices/rio_mport_cdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 76afe1449cab..3dd37e35cf4e 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -961,7 +961,7 @@ rio_dma_transfer(struct file *filp, u32 transfer_mode,
 
 	nents = dma_map_sg(chan->device->dev,
 			   req->sgt.sgl, req->sgt.nents, dir);
-	if (nents == -EFAULT) {
+	if (nents == 0) {
 		rmcd_error("Failed to map SG list");
 		ret = -EFAULT;
 		goto err_pg;
-- 
2.11.0

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

* [PATCH 2/2] rapidio: Fix an error handling in 'rio_dma_transfer()'
@ 2017-09-17 22:33   ` Christophe JAILLET
  0 siblings, 0 replies; 8+ messages in thread
From: Christophe JAILLET @ 2017-09-17 22:33 UTC (permalink / raw)
  To: mporter, alexandre.bounine, lstoakes, akpm, jesper.nilsson,
	christian.koenig, logang
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

In case of error, 'dma_map_sg()' returns 0, not a negative value.
There is BUG_ON() in 'dma_map_sg_attrs()'  which makes sure of that.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/rapidio/devices/rio_mport_cdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 76afe1449cab..3dd37e35cf4e 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -961,7 +961,7 @@ rio_dma_transfer(struct file *filp, u32 transfer_mode,
 
 	nents = dma_map_sg(chan->device->dev,
 			   req->sgt.sgl, req->sgt.nents, dir);
-	if (nents = -EFAULT) {
+	if (nents = 0) {
 		rmcd_error("Failed to map SG list");
 		ret = -EFAULT;
 		goto err_pg;
-- 
2.11.0


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

* Re: [PATCH 0/2] rapidio: Two fixes for 'rio_dma_transfer()'
  2017-09-17 22:33 ` Christophe JAILLET
@ 2017-09-18 16:04   ` Logan Gunthorpe
  -1 siblings, 0 replies; 8+ messages in thread
From: Logan Gunthorpe @ 2017-09-18 16:04 UTC (permalink / raw)
  To: Christophe JAILLET, mporter, alexandre.bounine, lstoakes, akpm,
	jesper.nilsson, christian.koenig
  Cc: linux-kernel, kernel-janitors

Hey,

I don't have any relation to the rapidio code short of making a small 
change to an API it used. But I reviewed both patches and they look 
correct to me.

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>

Logan

On 17/09/17 04:33 PM, Christophe JAILLET wrote:
> These 2 patches are really close and are both related to error handling
> in 'rio_dma_transfer()'.
> The first one fixes some resources leak in case of error.
> The 2nd one fixes a test so that the corresponding error can be handled
> correctly.
> 
> I've splitted this into 2 paches because the first one looks trivial to me.
> But the 2nd one should require more attention, IMO. The existing error
> handling was dead code because 'dma_map_sg()' can not return -EFAULT. So
> this error handling code has never been executed/tested and I can't test it
> myself.
> 
> Christophe JAILLET (2):
>    rapidio: Fix resources leak in error handling path in
>      'rio_dma_transfer()'
>    rapidio: Fix an error handling in 'rio_dma_transfer()'
> 
>   drivers/rapidio/devices/rio_mport_cdev.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 

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

* Re: [PATCH 0/2] rapidio: Two fixes for 'rio_dma_transfer()'
@ 2017-09-18 16:04   ` Logan Gunthorpe
  0 siblings, 0 replies; 8+ messages in thread
From: Logan Gunthorpe @ 2017-09-18 16:04 UTC (permalink / raw)
  To: Christophe JAILLET, mporter, alexandre.bounine, lstoakes, akpm,
	jesper.nilsson, christian.koenig
  Cc: linux-kernel, kernel-janitors

Hey,

I don't have any relation to the rapidio code short of making a small 
change to an API it used. But I reviewed both patches and they look 
correct to me.

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>

Logan

On 17/09/17 04:33 PM, Christophe JAILLET wrote:
> These 2 patches are really close and are both related to error handling
> in 'rio_dma_transfer()'.
> The first one fixes some resources leak in case of error.
> The 2nd one fixes a test so that the corresponding error can be handled
> correctly.
> 
> I've splitted this into 2 paches because the first one looks trivial to me.
> But the 2nd one should require more attention, IMO. The existing error
> handling was dead code because 'dma_map_sg()' can not return -EFAULT. So
> this error handling code has never been executed/tested and I can't test it
> myself.
> 
> Christophe JAILLET (2):
>    rapidio: Fix resources leak in error handling path in
>      'rio_dma_transfer()'
>    rapidio: Fix an error handling in 'rio_dma_transfer()'
> 
>   drivers/rapidio/devices/rio_mport_cdev.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 

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

end of thread, other threads:[~2017-09-18 16:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-17 22:33 [PATCH 0/2] rapidio: Two fixes for 'rio_dma_transfer()' Christophe JAILLET
2017-09-17 22:33 ` Christophe JAILLET
2017-09-17 22:33 ` [PATCH 1/2] rapidio: Fix resources leak in error handling path in 'rio_dma_transfer()' Christophe JAILLET
2017-09-17 22:33   ` Christophe JAILLET
2017-09-17 22:33 ` [PATCH 2/2] rapidio: Fix an error handling " Christophe JAILLET
2017-09-17 22:33   ` Christophe JAILLET
2017-09-18 16:04 ` [PATCH 0/2] rapidio: Two fixes for 'rio_dma_transfer()' Logan Gunthorpe
2017-09-18 16:04   ` Logan Gunthorpe

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.