[PATCH] scsi_transport_fc: remove useless check

2015-12-30 Thread Andrzej Hajda
simple_strtoul returns only non-negative values and *val is unsigned
so there is no possibility that *val is lesser than 0.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Signed-off-by: Andrzej Hajda 
---
 drivers/scsi/scsi_transport_fc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 8a88226..ecf62d9 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned 
long *val)
char *cp;
 
*val = simple_strtoul(buf, &cp, 0);
-   if ((*cp && (*cp != '\n')) || (*val < 0))
+   if (*cp && (*cp != '\n'))
return -EINVAL;
/*
 * Check for overflow; dev_loss_tmo is u32
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] be2iscsi: fix handling return value of mgmt_open_connection

2015-12-14 Thread Andrzej Hajda
The function can return negative values, so its result should
be assigned to signed variable.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

Signed-off-by: Andrzej Hajda 
---
 drivers/scsi/be2iscsi/be_iscsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index b7087ba..ce9f192 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -1106,8 +1106,8 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
struct beiscsi_hba *phba = beiscsi_ep->phba;
struct tcp_connect_and_offload_out *ptcpcnct_out;
struct be_dma_mem nonemb_cmd;
-   unsigned int tag, req_memsize;
-   int ret = -ENOMEM;
+   unsigned int req_memsize;
+   int tag, ret = -ENOMEM;
 
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : In beiscsi_open_conn\n");
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 17/31] scsi/aacraid: use kmemdup rather than duplicating its implementation

2015-09-16 Thread Andrzej Hajda
Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda 
> ---
>  drivers/scsi/aacraid/commctrl.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
> index 54195a1..d2ed626 100644
> --- a/drivers/scsi/aacraid/commctrl.c
> +++ b/drivers/scsi/aacraid/commctrl.c
> @@ -635,15 +635,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, void 
> __user * arg)
>   }
>   } else {
>   struct user_sgmap* usg;
> - usg = kmalloc(actual_fibsize - sizeof(struct aac_srb)
> -   + sizeof(struct sgmap), GFP_KERNEL);
> + usg = kmemdup(upsg,
> +   actual_fibsize - sizeof(struct aac_srb) + 
> sizeof(struct sgmap),
> +   GFP_KERNEL);
>   if (!usg) {
>   dprintk((KERN_DEBUG"aacraid: Allocation error 
> in Raw SRB command\n"));
>   rcode = -ENOMEM;
>   goto cleanup;
>   }
> - memcpy (usg, upsg, actual_fibsize - sizeof(struct 
> aac_srb)
> -   + sizeof(struct sgmap));
>   actual_fibsize = actual_fibsize64;
>  
>   for (i = 0; i < usg->count; i++) {

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 18/31] scsi/aic7xxx: use kmemdup rather than duplicating its implementation

2015-09-16 Thread Andrzej Hajda
Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda 
> ---
>  drivers/scsi/aic7xxx/aic79xx_core.c | 4 ++--
>  drivers/scsi/aic7xxx/aic7xxx_core.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c 
> b/drivers/scsi/aic7xxx/aic79xx_core.c
> index 109e2c9..8592448 100644
> --- a/drivers/scsi/aic7xxx/aic79xx_core.c
> +++ b/drivers/scsi/aic7xxx/aic79xx_core.c
> @@ -9494,10 +9494,10 @@ ahd_loadseq(struct ahd_softc *ahd)
>   if (cs_count != 0) {
>  
>   cs_count *= sizeof(struct cs);
> - ahd->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
> + ahd->critical_sections = kmemdup(cs_table, cs_count,
> +  GFP_ATOMIC);
>   if (ahd->critical_sections == NULL)
>   panic("ahd_loadseq: Could not malloc");
> - memcpy(ahd->critical_sections, cs_table, cs_count);
>   }
>   ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE);
>  
> diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c 
> b/drivers/scsi/aic7xxx/aic7xxx_core.c
> index c4829d8..3178730 100644
> --- a/drivers/scsi/aic7xxx/aic7xxx_core.c
> +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
> @@ -6940,10 +6940,10 @@ ahc_loadseq(struct ahc_softc *ahc)
>   if (cs_count != 0) {
>  
>   cs_count *= sizeof(struct cs);
> - ahc->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
> + ahc->critical_sections = kmemdup(cs_table, cs_count,
> +  GFP_ATOMIC);
>   if (ahc->critical_sections == NULL)
>   panic("ahc_loadseq: Could not malloc");
> - memcpy(ahc->critical_sections, cs_table, cs_count);
>   }
>   ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE);
>  

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 14/31] message/fusion: use kmemdup rather than duplicating its implementation

2015-09-16 Thread Andrzej Hajda
Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda 
> ---
>  drivers/message/fusion/mptbase.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/message/fusion/mptbase.c 
> b/drivers/message/fusion/mptbase.c
> index 5dcc031..1551f51 100644
> --- a/drivers/message/fusion/mptbase.c
> +++ b/drivers/message/fusion/mptbase.c
> @@ -5971,13 +5971,12 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
>   if (mpt_config(ioc, &cfg) != 0)
>   goto out;
>  
> - mem = kmalloc(iocpage2sz, GFP_KERNEL);
> + mem = kmemdup((u8 *)pIoc2, iocpage2sz, GFP_KERNEL);
>   if (!mem) {
>   rc = -ENOMEM;
>   goto out;
>   }
>  
> - memcpy(mem, (u8 *)pIoc2, iocpage2sz);
>   ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem;
>  
>   mpt_read_ioc_pg_3(ioc);

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/31] message/fusion: use kmemdup rather than duplicating its implementation

2015-08-07 Thread Andrzej Hajda
The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda 
---
 drivers/message/fusion/mptbase.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 5dcc031..1551f51 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -5971,13 +5971,12 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
if (mpt_config(ioc, &cfg) != 0)
goto out;
 
-   mem = kmalloc(iocpage2sz, GFP_KERNEL);
+   mem = kmemdup((u8 *)pIoc2, iocpage2sz, GFP_KERNEL);
if (!mem) {
rc = -ENOMEM;
goto out;
}
 
-   memcpy(mem, (u8 *)pIoc2, iocpage2sz);
ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem;
 
mpt_read_ioc_pg_3(ioc);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/31] scsi/aacraid: use kmemdup rather than duplicating its implementation

2015-08-07 Thread Andrzej Hajda
The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda 
---
 drivers/scsi/aacraid/commctrl.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 54195a1..d2ed626 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -635,15 +635,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, void 
__user * arg)
}
} else {
struct user_sgmap* usg;
-   usg = kmalloc(actual_fibsize - sizeof(struct aac_srb)
- + sizeof(struct sgmap), GFP_KERNEL);
+   usg = kmemdup(upsg,
+ actual_fibsize - sizeof(struct aac_srb) + 
sizeof(struct sgmap),
+ GFP_KERNEL);
if (!usg) {
dprintk((KERN_DEBUG"aacraid: Allocation error 
in Raw SRB command\n"));
rcode = -ENOMEM;
goto cleanup;
}
-   memcpy (usg, upsg, actual_fibsize - sizeof(struct 
aac_srb)
- + sizeof(struct sgmap));
actual_fibsize = actual_fibsize64;
 
for (i = 0; i < usg->count; i++) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/31] scsi/aic7xxx: use kmemdup rather than duplicating its implementation

2015-08-07 Thread Andrzej Hajda
The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda 
---
 drivers/scsi/aic7xxx/aic79xx_core.c | 4 ++--
 drivers/scsi/aic7xxx/aic7xxx_core.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c 
b/drivers/scsi/aic7xxx/aic79xx_core.c
index 109e2c9..8592448 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -9494,10 +9494,10 @@ ahd_loadseq(struct ahd_softc *ahd)
if (cs_count != 0) {
 
cs_count *= sizeof(struct cs);
-   ahd->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
+   ahd->critical_sections = kmemdup(cs_table, cs_count,
+GFP_ATOMIC);
if (ahd->critical_sections == NULL)
panic("ahd_loadseq: Could not malloc");
-   memcpy(ahd->critical_sections, cs_table, cs_count);
}
ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE);
 
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c 
b/drivers/scsi/aic7xxx/aic7xxx_core.c
index c4829d8..3178730 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -6940,10 +6940,10 @@ ahc_loadseq(struct ahc_softc *ahc)
if (cs_count != 0) {
 
cs_count *= sizeof(struct cs);
-   ahc->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
+   ahc->critical_sections = kmemdup(cs_table, cs_count,
+GFP_ATOMIC);
if (ahc->critical_sections == NULL)
panic("ahc_loadseq: Could not malloc");
-   memcpy(ahc->critical_sections, cs_table, cs_count);
}
ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html