linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5/15] drivers/scsi/bnx2fc/bnx2fc_io.c: adjust duplicate test
       [not found] <1358773378-4700-1-git-send-email-Julia.Lawall@lip6.fr>
@ 2013-01-21 13:02 ` Julia Lawall
  2013-01-21 23:05   ` Bhanu Prakash Gollapudi
  2013-01-21 13:02 ` [PATCH 10/15] drivers/scsi/csiostor/csio_lnode.c: " Julia Lawall
  1 sibling, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2013-01-21 13:02 UTC (permalink / raw)
  To: Bhanu Prakash Gollapudi
  Cc: kernel-janitors, James E.J. Bottomley, linux-scsi, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Delete successive tests to the same location.  The code tested the result
of a previous allocation, that itself was already tested.  It is changed to
test the result of the most recent allocation.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@s exists@
local idexpression y;
expression x,e;
@@

*if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
 { ... when forall
   return ...; }
... when != \(y = e\|y += e\|y -= e\|y |= e\|y &= e\|y++\|y--\|&y\)
    when != \(XT_GETPAGE(...,y)\|WMI_CMD_BUF(...)\)
*if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
 { ... when forall
   return ...; }
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/scsi/bnx2fc/bnx2fc_io.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 8d4626c..8bea53d 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -654,7 +654,7 @@ int bnx2fc_init_mp_req(struct bnx2fc_cmd *io_req)
 	mp_req->mp_resp_bd = dma_alloc_coherent(&hba->pcidev->dev, sz,
 						 &mp_req->mp_resp_bd_dma,
 						 GFP_ATOMIC);
-	if (!mp_req->mp_req_bd) {
+	if (!mp_req->mp_resp_bd) {
 		printk(KERN_ERR PFX "unable to alloc MP resp bd\n");
 		bnx2fc_free_mp_resc(io_req);
 		return FAILED;

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

* [PATCH 10/15] drivers/scsi/csiostor/csio_lnode.c: adjust duplicate test
       [not found] <1358773378-4700-1-git-send-email-Julia.Lawall@lip6.fr>
  2013-01-21 13:02 ` [PATCH 5/15] drivers/scsi/bnx2fc/bnx2fc_io.c: adjust duplicate test Julia Lawall
@ 2013-01-21 13:02 ` Julia Lawall
  2013-01-23  3:59   ` Naresh Kumar Inna
  1 sibling, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2013-01-21 13:02 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: kernel-janitors, linux-scsi, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Delete successive tests to the same location.  The current value of ln has
been tested already, and is clearly not NULL, given the enclosing if
condition.  Furthermore, the result of csio_lnode_alloc is currently
ignored.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@s exists@
local idexpression y;
expression x,e;
@@

*if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
 { ... when forall
   return ...; }
... when != \(y = e\|y += e\|y -= e\|y |= e\|y &= e\|y++\|y--\|&y\)
    when != \(XT_GETPAGE(...,y)\|WMI_CMD_BUF(...)\)
*if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
 { ... when forall
   return ...; }
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
Not tested.  I don't know if this is the right fix.

 drivers/scsi/csiostor/csio_lnode.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/csiostor/csio_lnode.c b/drivers/scsi/csiostor/csio_lnode.c
index ffe9be0..d956f97 100644
--- a/drivers/scsi/csiostor/csio_lnode.c
+++ b/drivers/scsi/csiostor/csio_lnode.c
@@ -873,7 +873,7 @@ csio_handle_link_up(struct csio_hw *hw, uint8_t portid, uint32_t fcfi,
 		if (ln->vnp_flowid != CSIO_INVALID_IDX) {
 			/* New VN-Port */
 			spin_unlock_irq(&hw->lock);
-			csio_lnode_alloc(hw);
+			ln = csio_lnode_alloc(hw);
 			spin_lock_irq(&hw->lock);
 			if (!ln) {
 				csio_err(hw,

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

* Re: [PATCH 5/15] drivers/scsi/bnx2fc/bnx2fc_io.c: adjust duplicate test
  2013-01-21 13:02 ` [PATCH 5/15] drivers/scsi/bnx2fc/bnx2fc_io.c: adjust duplicate test Julia Lawall
@ 2013-01-21 23:05   ` Bhanu Prakash Gollapudi
  0 siblings, 0 replies; 4+ messages in thread
From: Bhanu Prakash Gollapudi @ 2013-01-21 23:05 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, James E.J. Bottomley, linux-scsi, linux-kernel

On 01/21/2013 05:02 AM, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> Delete successive tests to the same location.  The code tested the result
> of a previous allocation, that itself was already tested.  It is changed to
> test the result of the most recent allocation.
>
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @s exists@
> local idexpression y;
> expression x,e;
> @@
>
> *if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
>   { ... when forall
>     return ...; }
> ... when != \(y = e\|y += e\|y -= e\|y |= e\|y &= e\|y++\|y--\|&y\)
>      when != \(XT_GETPAGE(...,y)\|WMI_CMD_BUF(...)\)
> *if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
>   { ... when forall
>     return ...; }
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>   drivers/scsi/bnx2fc/bnx2fc_io.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
> index 8d4626c..8bea53d 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_io.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
> @@ -654,7 +654,7 @@ int bnx2fc_init_mp_req(struct bnx2fc_cmd *io_req)
>   	mp_req->mp_resp_bd = dma_alloc_coherent(&hba->pcidev->dev, sz,
>   						 &mp_req->mp_resp_bd_dma,
>   						 GFP_ATOMIC);
> -	if (!mp_req->mp_req_bd) {
> +	if (!mp_req->mp_resp_bd) {
>   		printk(KERN_ERR PFX "unable to alloc MP resp bd\n");
>   		bnx2fc_free_mp_resc(io_req);
>   		return FAILED;
>
>
Acked-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>

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

* Re: [PATCH 10/15] drivers/scsi/csiostor/csio_lnode.c: adjust duplicate test
  2013-01-21 13:02 ` [PATCH 10/15] drivers/scsi/csiostor/csio_lnode.c: " Julia Lawall
@ 2013-01-23  3:59   ` Naresh Kumar Inna
  0 siblings, 0 replies; 4+ messages in thread
From: Naresh Kumar Inna @ 2013-01-23  3:59 UTC (permalink / raw)
  To: Julia Lawall
  Cc: James E.J. Bottomley, kernel-janitors@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org

On 1/21/2013 6:32 PM, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Delete successive tests to the same location.  The current value of ln has
> been tested already, and is clearly not NULL, given the enclosing if
> condition.  Furthermore, the result of csio_lnode_alloc is currently
> ignored.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @s exists@
> local idexpression y;
> expression x,e;
> @@
> 
> *if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
>  { ... when forall
>    return ...; }
> ... when != \(y = e\|y += e\|y -= e\|y |= e\|y &= e\|y++\|y--\|&y\)
>     when != \(XT_GETPAGE(...,y)\|WMI_CMD_BUF(...)\)
> *if ( \(x == NULL\|IS_ERR(x)\|y != 0\) )
>  { ... when forall
>    return ...; }
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
> Not tested.  I don't know if this is the right fix.
> 
>  drivers/scsi/csiostor/csio_lnode.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/csiostor/csio_lnode.c b/drivers/scsi/csiostor/csio_lnode.c
> index ffe9be0..d956f97 100644
> --- a/drivers/scsi/csiostor/csio_lnode.c
> +++ b/drivers/scsi/csiostor/csio_lnode.c
> @@ -873,7 +873,7 @@ csio_handle_link_up(struct csio_hw *hw, uint8_t portid, uint32_t fcfi,
>  		if (ln->vnp_flowid != CSIO_INVALID_IDX) {
>  			/* New VN-Port */
>  			spin_unlock_irq(&hw->lock);
> -			csio_lnode_alloc(hw);
> +			ln = csio_lnode_alloc(hw);
>  			spin_lock_irq(&hw->lock);
>  			if (!ln) {
>  				csio_err(hw,
> --

Acked-by: Naresh Kumar Inna <naresh@chelsio.com>

Thanks,
Naresh.

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

end of thread, other threads:[~2013-01-23  3:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1358773378-4700-1-git-send-email-Julia.Lawall@lip6.fr>
2013-01-21 13:02 ` [PATCH 5/15] drivers/scsi/bnx2fc/bnx2fc_io.c: adjust duplicate test Julia Lawall
2013-01-21 23:05   ` Bhanu Prakash Gollapudi
2013-01-21 13:02 ` [PATCH 10/15] drivers/scsi/csiostor/csio_lnode.c: " Julia Lawall
2013-01-23  3:59   ` Naresh Kumar Inna

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).