Re: [PATCH] sym53c8xx: fix bad memset argument in sym_set_cam_result_error

2008-01-26 Thread Mariusz Kozlowski
Hello,

 On a big powerpc box I got the following oops with 2.6.24-git2:
 
 sym0: 1010-66 rev 0x1 at pci :d0:01.0 irq 215
 sym0: No NVRAM, ID 7, Fast-80, LVD, parity checking
 sym0: SCSI BUS has been reset.
 scsi0 : sym-2.2.3
  target0:0:8: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 31)
 scsi 0:0:8:0: Direct-Access IBM  ST318305LC   C509 PQ: 0
 ANSI: 3
  target0:0:8: tagged command queuing enabled, command queue depth 16.
  target0:0:8: Beginning Domain Validation
  target0:0:8: asynchronous
  target0:0:8: wide asynchronous
  target0:0:8: FAST-80 WIDE SCSI 160.0 MB/s DT (12.5 ns, offset 31)
  target0:0:8: FAST-80 WIDE SCSI 160.0 MB/s DT (12.5 ns, offset 31)
 Unable to handle kernel paging request for data at address 0x
 Faulting instruction address: 0xc0038460
 cpu 0x25: Vector: 300 (Data Access) at [cf567840]
 pc: c0038460: .memcpy+0x60/0x280
 lr: d0050280: .sym_set_cam_result_error+0xfc/0x1e0 [sym53c8xx]
 sp: cf567ac0
msr: 80009032
dar: 0
  dsisr: 4200
   current = 0xc06d1e0af0a0
   paca= 0xc04afc00
 pid   = 0, comm = swapper
 enter ? for help
 [link register   ] d0050280
 .sym_set_cam_result_error+0xfc/0x1e0 [sym53c8xx]
 [cf567ac0] cf567b80 (unreliable)
 [cf567b80] d00552b8 .sym_complete_error+0x12c/0x1bc 
 [sym53c8xx]
 [cf567c20] d00561a4 .sym_int_sir+0xaa4/0x1718 [sym53c8xx]
 [cf567d00] d0057e8c .sym_interrupt+0x4e4/0x6ec [sym53c8xx]
 [cf567dc0] d004fdf4 .sym53c8xx_intr+0x6c/0xdc [sym53c8xx]
 [cf567e50] c00a83e0 .handle_IRQ_event+0x7c/0xec
 [cf567ef0] c00aa344 .handle_fasteoi_irq+0x130/0x1f0
 [cf567f90] c002a538 .call_handle_irq+0x1c/0x2c
 [c04d5e0b3a90] c000c320 .do_IRQ+0x108/0x1d0
 [c04d5e0b3b20] c0004790 hardware_interrupt_entry+0x18/0x1c
 
 The memset() in sym_set_cam_result_error() would appear to be trashing
 the scsi_cmnd struct instead of clearing sense_buffer.
 
 Signed-off-by: Nathan Lynch [EMAIL PROTECTED]
 ---
  drivers/scsi/sym53c8xx_2/sym_glue.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c 
 b/drivers/scsi/sym53c8xx_2/sym_glue.c
 index 21e926d..e939f38 100644
 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c
 +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
 @@ -207,7 +207,7 @@ void sym_set_cam_result_error(struct sym_hcb *np, struct 
 sym_ccb *cp, int resid)
   /*
*  Bounce back the sense data to user.
*/
 - memset(cmd-sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 + memset(cmd-sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
   memcpy(cmd-sense_buffer, cp-sns_bbuf,
  min(SCSI_SENSE_BUFFERSIZE, SYM_SNS_BBUF_LEN));
  #if 0

I was looking into it and found something interesting. What you see was just 
exposed by:

commit b80ca4f7ee36c26d300c5a8f429e73372d153379
Author: FUJITA Tomonori [EMAIL PROTECTED]
Date:   Sun Jan 13 15:46:13 2008 +0900

[SCSI] replace sizeof sense_buffer with  

This replaces sizeof sense_buffer with SCSI_SENSE_BUFFERSIZE in
several LLDs. It's a preparation for the future changes to remove
sense_buffer array in scsi_cmnd structure.

Signed-off-by: FUJITA Tomonori [EMAIL PROTECTED]
Signed-off-by: James Bottomley [EMAIL PROTECTED]

But this is not a simple replace sizeof sense_buffer with SCSI_SENSE_BUFFERSIZE
It has a side effect. Take a look a this portion of the commit:

--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -207,10 +207,9 @@ void sym_set_cam_result_error(struct sym_hcb *np, struct 
sym_ccb *cp, int resid)
/*
 *  Bounce back the sense data to user.
 */
-   memset(cmd-sense_buffer, 0, 
sizeof(cmd-sense_buffer));
+   memset(cmd-sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
memcpy(cmd-sense_buffer, cp-sns_bbuf,
- min(sizeof(cmd-sense_buffer),
- (size_t)SYM_SNS_BBUF_LEN));
+  min(SCSI_SENSE_BUFFERSIZE, SYM_SNS_BBUF_LEN));

Before the patch:
1) memset sets cmd-sense_buffer pointer value to zero (only 4 bytes which is 
wrong)
2) memcpy copies min(sizeof(cmd-sense_buffer), (size_t)SYM_SNS_BBUF_LEN)) which
   is equal to min(4, 32) so after this only first four bytes were copied from 
32 bytes
   long cp-sns_bbuf into the sense_buffer

After the patch:
1) memset zeroes 96 bytes of cmd structure starting at offset where 
sense_buffer in
   cmd is and results in an oops which you fixed
2) memcpy copies min(SCSI_SENSE_BUFFERSIZE, SYM_SNS_BBUF_LEN)) is equal to
   min(96, 32). cp-sns_bbuf is 32 bytes so I guess 

Re: [PATCH] sym53c8xx: fix bad memset argument in sym_set_cam_result_error

2008-01-26 Thread Mariusz Kozlowski
Hello,

   On a big powerpc box I got the following oops with 2.6.24-git2:
   
   sym0: 1010-66 rev 0x1 at pci :d0:01.0 irq 215
   sym0: No NVRAM, ID 7, Fast-80, LVD, parity checking
   sym0: SCSI BUS has been reset.
   scsi0 : sym-2.2.3
target0:0:8: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 31)
   scsi 0:0:8:0: Direct-Access IBM  ST318305LC   C509 PQ: 0
   ANSI: 3
target0:0:8: tagged command queuing enabled, command queue depth 16.
target0:0:8: Beginning Domain Validation
target0:0:8: asynchronous
target0:0:8: wide asynchronous
target0:0:8: FAST-80 WIDE SCSI 160.0 MB/s DT (12.5 ns, offset 31)
target0:0:8: FAST-80 WIDE SCSI 160.0 MB/s DT (12.5 ns, offset 31)
   Unable to handle kernel paging request for data at address 0x
   Faulting instruction address: 0xc0038460
   cpu 0x25: Vector: 300 (Data Access) at [cf567840]
   pc: c0038460: .memcpy+0x60/0x280
   lr: d0050280: .sym_set_cam_result_error+0xfc/0x1e0 [sym53c8xx]
   sp: cf567ac0
  msr: 80009032
  dar: 0
dsisr: 4200
 current = 0xc06d1e0af0a0
 paca= 0xc04afc00
   pid   = 0, comm = swapper
   enter ? for help
   [link register   ] d0050280
   .sym_set_cam_result_error+0xfc/0x1e0 [sym53c8xx]
   [cf567ac0] cf567b80 (unreliable)
   [cf567b80] d00552b8 .sym_complete_error+0x12c/0x1bc 
   [sym53c8xx]
   [cf567c20] d00561a4 .sym_int_sir+0xaa4/0x1718 [sym53c8xx]
   [cf567d00] d0057e8c .sym_interrupt+0x4e4/0x6ec [sym53c8xx]
   [cf567dc0] d004fdf4 .sym53c8xx_intr+0x6c/0xdc [sym53c8xx]
   [cf567e50] c00a83e0 .handle_IRQ_event+0x7c/0xec
   [cf567ef0] c00aa344 .handle_fasteoi_irq+0x130/0x1f0
   [cf567f90] c002a538 .call_handle_irq+0x1c/0x2c
   [c04d5e0b3a90] c000c320 .do_IRQ+0x108/0x1d0
   [c04d5e0b3b20] c0004790 hardware_interrupt_entry+0x18/0x1c
   
   The memset() in sym_set_cam_result_error() would appear to be trashing
   the scsi_cmnd struct instead of clearing sense_buffer.
   
   Signed-off-by: Nathan Lynch [EMAIL PROTECTED]
   ---
drivers/scsi/sym53c8xx_2/sym_glue.c |2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
   
   diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c 
   b/drivers/scsi/sym53c8xx_2/sym_glue.c
   index 21e926d..e939f38 100644
   --- a/drivers/scsi/sym53c8xx_2/sym_glue.c
   +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
   @@ -207,7 +207,7 @@ void sym_set_cam_result_error(struct sym_hcb *np, 
   struct sym_ccb *cp, int resid)
 /*
  *  Bounce back the sense data to user.
  */
   - memset(cmd-sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
   + memset(cmd-sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 memcpy(cmd-sense_buffer, cp-sns_bbuf,
min(SCSI_SENSE_BUFFERSIZE, SYM_SNS_BBUF_LEN));
#if 0
  
  I was looking into it and found something interesting. What you see was 
  just exposed by:
  
  commit b80ca4f7ee36c26d300c5a8f429e73372d153379
  Author: FUJITA Tomonori [EMAIL PROTECTED]
  Date:   Sun Jan 13 15:46:13 2008 +0900
  
  [SCSI] replace sizeof sense_buffer with  
  
  This replaces sizeof sense_buffer with SCSI_SENSE_BUFFERSIZE in
  several LLDs. It's a preparation for the future changes to remove
  sense_buffer array in scsi_cmnd structure.
  
  Signed-off-by: FUJITA Tomonori [EMAIL PROTECTED]
  Signed-off-by: James Bottomley [EMAIL PROTECTED]
  
  But this is not a simple replace sizeof sense_buffer with 
  SCSI_SENSE_BUFFERSIZE
  It has a side effect. Take a look a this portion of the commit:
  
  --- a/drivers/scsi/sym53c8xx_2/sym_glue.c
  +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
  @@ -207,10 +207,9 @@ void sym_set_cam_result_error(struct sym_hcb *np, 
  struct sym_ccb *cp, int resid)
  /*
   *  Bounce back the sense data to user.
   */
  -   memset(cmd-sense_buffer, 0, 
  sizeof(cmd-sense_buffer));
  +   memset(cmd-sense_buffer, 0, 
  SCSI_SENSE_BUFFERSIZE);
  memcpy(cmd-sense_buffer, cp-sns_bbuf,
  - min(sizeof(cmd-sense_buffer),
  - (size_t)SYM_SNS_BBUF_LEN));
  +  min(SCSI_SENSE_BUFFERSIZE, 
  SYM_SNS_BBUF_LEN));
  
  Before the patch:
  1) memset sets cmd-sense_buffer pointer value to zero (only 4 bytes which 
  is wrong)
  2) memcpy copies min(sizeof(cmd-sense_buffer), (size_t)SYM_SNS_BBUF_LEN)) 
  which
 is equal to min(4, 32) so after this only first four bytes were copied 
  from 32 bytes
 long cp-sns_bbuf into the sense_buffer
 
 This logic is wrong.  There was a commit
 

Re: [patch 20/30] drivers/scsi/gdth.c: kmalloc + memset conversion to kzalloc

2007-08-11 Thread Mariusz Kozlowski
  From: Mariusz Kozlowski [EMAIL PROTECTED]
  
   drivers/scsi/gdth.c | 189401 - 189342 (-59 bytes)
   drivers/scsi/gdth.o | 331028 - 330324 (-704 bytes)
 
 For the second time of asking, could I just have a single patch doing
 this globally for the entirety of SCSI with reasonable assurance of
 mechanical checking.
 
 There's no real need to collect maintainer acks for something as trivial
 as this.

Ok, here it goes. But some of them are already in -rc2-mm2 I guess.

Regards,

Mariusz



Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/NCR_D700.c  |4 ++--
 drivers/scsi/a4000t.c|7 +++
 drivers/scsi/aic7xxx_old.c   |8 +++-
 drivers/scsi/bvme6000_scsi.c |7 +++
 drivers/scsi/dpt_i2o.c   |   27 +++
 drivers/scsi/gdth.c  |8 
 drivers/scsi/ide-scsi.c  |   10 --
 drivers/scsi/lpfc/lpfc_debugfs.c |7 ++-
 drivers/scsi/lpfc/lpfc_init.c|3 +--
 drivers/scsi/lpfc/lpfc_scsi.c|3 +--
 drivers/scsi/megaraid.c  |3 +--
 drivers/scsi/mvme16x_scsi.c  |3 +--
 drivers/scsi/osst.c  |5 ++---
 drivers/scsi/pluto.c |   24 +---
 drivers/scsi/qla2xxx/qla_init.c  |   14 ++
 drivers/scsi/zorro7xx.c  |8 +++-
 16 files changed, 60 insertions(+), 81 deletions(-)

diff -upr linux-2.6.23-rc1-mm1-a/drivers/scsi/NCR_D700.c 
linux-2.6.23-rc1-mm1-b/drivers/scsi/NCR_D700.c
--- linux-2.6.23-rc1-mm1-a/drivers/scsi/NCR_D700.c  2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/NCR_D700.c  2007-07-31 
11:13:37.0 +0200
@@ -313,10 +313,10 @@ NCR_D700_probe(struct device *dev)
break;
}

-   p = kmalloc(sizeof(*p), GFP_KERNEL);
+   p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p)
return -ENOMEM;
-   memset(p, '\0', sizeof(*p));
+
p-dev = dev;
snprintf(p-name, sizeof(p-name), D700(%s), dev-bus_id);
if (request_irq(irq, NCR_D700_intr, IRQF_SHARED, p-name, p)) {
diff -upr linux-2.6.23-rc1-mm1-a/drivers/scsi/a4000t.c 
linux-2.6.23-rc1-mm1-b/drivers/scsi/a4000t.c
--- linux-2.6.23-rc1-mm1-a/drivers/scsi/a4000t.c2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/a4000t.c2007-07-31 
14:00:37.0 +0200
@@ -37,7 +37,7 @@ static struct platform_device *a4000t_sc

 static int __devinit a4000t_probe(struct device *dev)
 {
-   struct Scsi_Host * host = NULL;
+   struct Scsi_Host *host;
struct NCR_700_Host_Parameters *hostdata;

if (!(MACH_IS_AMIGA  AMIGAHW_PRESENT(A4000_SCSI)))
@@ -47,12 +47,11 @@ static int __devinit a4000t_probe(struct
A4000T builtin SCSI))
goto out;

-   hostdata = kmalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
-   if (hostdata == NULL) {
+   hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
+   if (!hostdata) {
printk(KERN_ERR a4000t-scsi: Failed to allocate host data\n);
goto out_release;
}
-   memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));

/* Fill in the required pieces of hostdata */
hostdata-base = (void __iomem *)ZTWO_VADDR(A4000T_SCSI_ADDR);
diff -upr linux-2.6.23-rc1-mm1-a/drivers/scsi/aic7xxx_old.c 
linux-2.6.23-rc1-mm1-b/drivers/scsi/aic7xxx_old.c
--- linux-2.6.23-rc1-mm1-a/drivers/scsi/aic7xxx_old.c   2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/aic7xxx_old.c   2007-07-31 
14:03:31.0 +0200
@@ -8416,10 +8416,9 @@ aic7xxx_alloc(struct scsi_host_template
 *p = *temp;
 p-host = host;

-p-scb_data = kmalloc(sizeof(scb_data_type), GFP_ATOMIC);
-if (p-scb_data != NULL)
+p-scb_data = kzalloc(sizeof(scb_data_type), GFP_ATOMIC);
+if (!p-scb_data)
 {
-  memset(p-scb_data, 0, sizeof(scb_data_type));
   scbq_init (p-scb_data-free_scbs);
 }
 else
@@ -9196,10 +9195,9 @@ aic7xxx_detect(struct scsi_host_template
 printk(KERN_INFO  this driver, we are ignoring it.\n);
   }
 }
-else if ( (temp_p = kmalloc(sizeof(struct aic7xxx_host),
+else if ( (temp_p = kzalloc(sizeof(struct aic7xxx_host),
 GFP_ATOMIC)) != NULL )
 {
-  memset(temp_p, 0, sizeof(struct aic7xxx_host));
   temp_p-chip = aic_pdevs[i].chip | AHC_PCI;
   temp_p-flags = aic_pdevs[i].flags;
   temp_p-features = aic_pdevs[i].features;
diff -upr linux-2.6.23-rc1-mm1-a/drivers/scsi/bvme6000_scsi.c 
linux-2.6.23-rc1-mm1-b/drivers/scsi/bvme6000_scsi.c
--- linux-2.6.23-rc1-mm1-a/drivers/scsi/bvme6000_scsi.c 2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/bvme6000_scsi.c 2007-07-31 
14:04:50.0 +0200
@@ -36,19 +36,18 @@ static

[PATCH -mm] drivers/scsi/megaraid.c: bugfix

2007-08-11 Thread Mariusz Kozlowski
Hello,

This is one of the 'possible downsides: embarrassment' situation 
described
by Randy in his papers on linux development. I introduced a bug while doin 
conversion
to kzalloc and this is a fix. We can not return here as we are under lock. Live 
and learn.

Please apply.

Regards,

Mariusz

Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/megaraid.c | 116094 - 116063 (-31 bytes)
 drivers/scsi/megaraid.o | 257984 - 257868 (-116 bytes)

 drivers/scsi/megaraid.c |3 ---
 1 file changed, 3 deletions(-)

--- linux-2.6.23-rc2-mm2-a/drivers/scsi/megaraid.c  2007-08-10 
12:46:10.0 +0200
+++ linux-2.6.23-rc2-mm2-b/drivers/scsi/megaraid.c  2007-08-11 
10:03:25.0 +0200
@@ -4409,9 +4409,6 @@ mega_internal_command(adapter_t *adapter
memset(scmd, 0, sizeof(Scsi_Cmnd));

sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
-   if (!sdev)
-   return -ENOMEM;
-
scmd-device = sdev;

scmd-device-host = adapter-host;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] message/fusion: remove redundant memset

2007-08-08 Thread Mariusz Kozlowski
Hello,

alloc_fcdev() calls alloc_netdev() which uses kzalloc to alloc
all the memory together with dev-priv region hence no zeroing of structs
inside struct mpt_lan_priv needed.

Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/message/fusion/mptlan.c | 47738 - 47618 (-120 bytes)
 drivers/message/fusion/mptlan.o | 170800 - 170124 (-676 bytes)

 drivers/message/fusion/mptlan.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

--- linux-2.6.23-rc1-mm2-a/drivers/message/fusion/mptlan.c  2007-08-01 
08:43:47.0 +0200
+++ linux-2.6.23-rc1-mm2-b/drivers/message/fusion/mptlan.c  2007-08-07 
01:33:49.0 +0200
@@ -1351,10 +1351,11 @@ mpt_lan_post_receive_buckets_work(struct
 static struct net_device *
 mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
 {
-   struct net_device *dev = alloc_fcdev(sizeof(struct mpt_lan_priv));
-   struct mpt_lan_priv *priv = NULL;
+   struct net_device *dev;
+   struct mpt_lan_priv *priv;
u8 HWaddr[FC_ALEN], *a;

+   dev = alloc_fcdev(sizeof(struct mpt_lan_priv));
if (!dev)
return NULL;

@@ -1366,7 +1367,6 @@ mpt_register_lan_device (MPT_ADAPTER *mp
priv-mpt_dev = mpt_dev;
priv-pnum = pnum;

-   memset(priv-post_buckets_task, 0, sizeof(priv-post_buckets_task));
INIT_DELAYED_WORK(priv-post_buckets_task,
  mpt_lan_post_receive_buckets_work);
priv-post_buckets_active = 0;
@@ -1391,8 +1391,6 @@ mpt_register_lan_device (MPT_ADAPTER *mp
spin_lock_init(priv-txfidx_lock);
spin_lock_init(priv-rxfidx_lock);

-   memset(priv-stats, 0, sizeof(priv-stats));
-
/*  Grab pre-fetched LANPage1 stuff. :-) */
a = (u8 *) mpt_dev-lan_cnfg_page1.HardwareAddressLow;

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


[PATCH 01] kmalloc + memset conversion co kzalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/a4000t.c | 3534 - 3457 (-77 bytes)

 drivers/scsi/a4000t.c |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/a4000t.c2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/a4000t.c2007-07-31 
14:00:37.0 +0200
@@ -37,7 +37,7 @@ static struct platform_device *a4000t_sc

 static int __devinit a4000t_probe(struct device *dev)
 {
-   struct Scsi_Host * host = NULL;
+   struct Scsi_Host *host;
struct NCR_700_Host_Parameters *hostdata;

if (!(MACH_IS_AMIGA  AMIGAHW_PRESENT(A4000_SCSI)))
@@ -47,12 +47,11 @@ static int __devinit a4000t_probe(struct
A4000T builtin SCSI))
goto out;

-   hostdata = kmalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
-   if (hostdata == NULL) {
+   hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
+   if (!hostdata) {
printk(KERN_ERR a4000t-scsi: Failed to allocate host data\n);
goto out_release;
}
-   memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));

/* Fill in the required pieces of hostdata */
hostdata-base = (void __iomem *)ZTWO_VADDR(A4000T_SCSI_ADDR);
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02] kmalloc + memset conversion to kzalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/aic7xxx_old.c | 367101 - 366983 (-118 bytes)
 drivers/scsi/aic7xxx_old.o | 333892 - 333192 (-700 bytes)

 drivers/scsi/aic7xxx_old.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/aic7xxx_old.c   2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/aic7xxx_old.c   2007-07-31 
14:03:31.0 +0200
@@ -8416,10 +8416,9 @@ aic7xxx_alloc(struct scsi_host_template
 *p = *temp;
 p-host = host;

-p-scb_data = kmalloc(sizeof(scb_data_type), GFP_ATOMIC);
-if (p-scb_data != NULL)
+p-scb_data = kzalloc(sizeof(scb_data_type), GFP_ATOMIC);
+if (!p-scb_data)
 {
-  memset(p-scb_data, 0, sizeof(scb_data_type));
   scbq_init (p-scb_data-free_scbs);
 }
 else
@@ -9196,10 +9195,9 @@ aic7xxx_detect(struct scsi_host_template
 printk(KERN_INFO  this driver, we are ignoring it.\n);
   }
 }
-else if ( (temp_p = kmalloc(sizeof(struct aic7xxx_host),
+else if ( (temp_p = kzalloc(sizeof(struct aic7xxx_host),
 GFP_ATOMIC)) != NULL )
 {
-  memset(temp_p, 0, sizeof(struct aic7xxx_host));
   temp_p-chip = aic_pdevs[i].chip | AHC_PCI;
   temp_p-flags = aic_pdevs[i].flags;
   temp_p-features = aic_pdevs[i].features;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06] drivers/scsi/bvme6000_scsi.c: kmalloc + memset conversion to kzalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/bvme6000_scsi.c | 3330 - 3253 (-77 bytes)

 drivers/scsi/bvme6000_scsi.c |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/bvme6000_scsi.c 2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/bvme6000_scsi.c 2007-07-31 
14:04:50.0 +0200
@@ -36,19 +36,18 @@ static struct platform_device *bvme6000_
 static __devinit int
 bvme6000_probe(struct device *dev)
 {
-   struct Scsi_Host * host = NULL;
+   struct Scsi_Host *host;
struct NCR_700_Host_Parameters *hostdata;

if (!MACH_IS_BVME6000)
goto out;

-   hostdata = kmalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
-   if (hostdata == NULL) {
+   hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
+   if (!hostdata) {
printk(KERN_ERR bvme6000-scsi: 
Failed to allocate host data\n);
goto out;
}
-   memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));

/* Fill in the required pieces of hostdata */
hostdata-base = (void __iomem *)BVME_NCR53C710_BASE;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21] drivers/scsi/dpt_i2o.c: kmalloc + memset conversion to kzalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/dpt_i2o.c | 87632 - 87457 (-175 bytes)
 drivers/scsi/dpt_i2o.o | 213064 - 212324 (-740 bytes)

 drivers/scsi/dpt_i2o.c |   27 +++
 1 file changed, 11 insertions(+), 16 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/dpt_i2o.c   2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/dpt_i2o.c   2007-07-31 
11:17:32.0 +0200
@@ -950,16 +950,14 @@ static int adpt_install_hba(struct scsi_
}

// Allocate and zero the data structure
-   pHba = kmalloc(sizeof(adpt_hba), GFP_KERNEL);
-   if( pHba == NULL) {
-   if(msg_addr_virt != base_addr_virt){
+   pHba = kzalloc(sizeof(adpt_hba), GFP_KERNEL);
+   if (!pHba) {
+   if (msg_addr_virt != base_addr_virt)
iounmap(msg_addr_virt);
-   }
iounmap(base_addr_virt);
pci_release_regions(pDev);
return -ENOMEM;
}
-   memset(pHba, 0, sizeof(adpt_hba));

mutex_lock(adpt_configuration_lock);

@@ -2667,14 +2665,13 @@ static s32 adpt_i2o_init_outbound_q(adpt

msg=(u32 __iomem *)(pHba-msg_addr_virt+m);

-   status = kmalloc(4,GFP_KERNEL|ADDR32);
-   if (status==NULL) {
+   status = kzalloc(4, GFP_KERNEL|ADDR32);
+   if (!status) {
adpt_send_nop(pHba, m);
printk(KERN_WARNING%s: IOP reset failed - no free memory.\n,
pHba-name);
return -ENOMEM;
}
-   memset(status, 0, 4);

writel(EIGHT_WORD_MSG_SIZE| SGL_OFFSET_6, msg[0]);
writel(I2O_CMD_OUTBOUND_INIT24 | HOST_TID12 | ADAPTER_TID, msg[1]);
@@ -2713,12 +2710,11 @@ static s32 adpt_i2o_init_outbound_q(adpt

kfree(pHba-reply_pool);

-   pHba-reply_pool = kmalloc(pHba-reply_fifo_size * REPLY_FRAME_SIZE * 
4, GFP_KERNEL|ADDR32);
-   if(!pHba-reply_pool){
-   printk(KERN_ERR%s: Could not allocate reply 
pool\n,pHba-name);
-   return -1;
+   pHba-reply_pool = kzalloc(pHba-reply_fifo_size * REPLY_FRAME_SIZE * 
4, GFP_KERNEL|ADDR32);
+   if (!pHba-reply_pool) {
+   printk(KERN_ERR %s: Could not allocate reply pool\n, 
pHba-name);
+   return -ENOMEM;
}
-   memset(pHba-reply_pool, 0 , pHba-reply_fifo_size * REPLY_FRAME_SIZE * 
4);

ptr = pHba-reply_pool;
for(i = 0; i  pHba-reply_fifo_size; i++) {
@@ -2929,12 +2925,11 @@ static int adpt_i2o_build_sys_table(void

kfree(sys_tbl);

-   sys_tbl = kmalloc(sys_tbl_len, GFP_KERNEL|ADDR32);
-   if(!sys_tbl) {
+   sys_tbl = kzalloc(sys_tbl_len, GFP_KERNEL|ADDR32);
+   if (!sys_tbl) {
printk(KERN_WARNING SysTab Set failed. Out of memory.\n);
return -ENOMEM;
}
-   memset(sys_tbl, 0, sys_tbl_len);

sys_tbl-num_entries = hba_count;
sys_tbl-version = I2OVERSION;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 26] drivers/scsi/gdth.c: kmalloc + memset conversion to kzalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/gdth.c | 189401 - 189342 (-59 bytes)
 drivers/scsi/gdth.o | 331028 - 330324 (-704 bytes)

 drivers/scsi/gdth.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/gdth.c  2007-07-26 13:07:42.0 
+0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/gdth.c  2007-07-31 14:08:37.0 
+0200
@@ -458,10 +458,10 @@ int __gdth_execute(struct scsi_device *s
 DECLARE_COMPLETION_ONSTACK(wait);
 int rval;

-scp = kmalloc(sizeof(*scp), GFP_KERNEL);
+scp = kzalloc(sizeof(*scp), GFP_KERNEL);
 if (!scp)
 return -ENOMEM;
-memset(scp, 0, sizeof(*scp));
+
 scp-device = sdev;
 /* use request field to save the ptr. to completion struct. */
 scp-request = (struct request *)wait;
@@ -5273,10 +5273,10 @@ static int gdth_ioctl(struct inode *inod
 hanum = res.ionode;
 ha = gdth_find_ha(hanum);

-scp  = kmalloc(sizeof(*scp), GFP_KERNEL);
+scp = kzalloc(sizeof(*scp), GFP_KERNEL);
 if (!scp)
 return -ENOMEM;
-memset(scp, 0, sizeof(*scp));
+
 scp-device = ha-sdev;
 scp-cmd_len = 12;
 scp-use_sg = 0;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 31] drivers/scsi/ide-scsi.c: kmalloc + memset conversion to kzalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/ide-scsi.c | 34642 - 34536 (-106 bytes)
 drivers/scsi/ide-scsi.o | 171728 - 171524 (-204 bytes)

 drivers/scsi/ide-scsi.c |   10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/ide-scsi.c  2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/ide-scsi.c  2007-07-31 
14:09:51.0 +0200
@@ -328,17 +328,15 @@ static int idescsi_check_condition(ide_d
u8 *buf;

/* stuff a sense request in front of our current request */
-   pc = kmalloc (sizeof (idescsi_pc_t), GFP_ATOMIC);
-   rq = kmalloc (sizeof (struct request), GFP_ATOMIC);
-   buf = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC);
-   if (pc == NULL || rq == NULL || buf == NULL) {
+   pc = kzalloc(sizeof(idescsi_pc_t), GFP_ATOMIC);
+   rq = kmalloc(sizeof(struct request), GFP_ATOMIC);
+   buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC);
+   if (!pc || !rq || !buf) {
kfree(buf);
kfree(rq);
kfree(pc);
return -ENOMEM;
}
-   memset (pc, 0, sizeof (idescsi_pc_t));
-   memset (buf, 0, SCSI_SENSE_BUFFERSIZE);
ide_init_drive_cmd(rq);
rq-special = (char *) pc;
pc-rq = rq;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 44] drivers/scsi/lpfc/lpfc_debugfs.c: kmalloc + memset conversion to kcalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/lpfc/lpfc_debugfs.c | 13809 - 13716 (-93 bytes)
 drivers/scsi/lpfc/lpfc_debugfs.o | 146124 - 146124 (0 bytes)

 drivers/scsi/lpfc/lpfc_debugfs.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/lpfc/lpfc_debugfs.c 2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/lpfc/lpfc_debugfs.c 2007-07-31 
14:11:24.0 +0200
@@ -432,14 +432,11 @@ lpfc_debugfs_initialize(struct lpfc_vpor
if (!lpfc_debugfs_start_time)
lpfc_debugfs_start_time = jiffies;

-   vport-disc_trc = kmalloc(
-   (sizeof(struct lpfc_disc_trc) * lpfc_debugfs_max_disc_trc),
-   GFP_KERNEL);
+   vport-disc_trc = kcalloc(lpfc_debugfs_max_disc_trc,
+ sizeof(struct lpfc_disc_trc), GFP_KERNEL);

if (!vport-disc_trc)
goto debug_failed;
-   memset(vport-disc_trc, 0,
-   (sizeof(struct lpfc_disc_trc) * lpfc_debugfs_max_disc_trc));

snprintf(name, sizeof(name), discovery_trace);
vport-debug_disc_trc =
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 45] drivers/scsi/lpfc/lpfc_init.c: kmalloc + memset conversion to kcalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/lpfc/lpfc_init.c | 65932 - 65881 (-51 bytes)
 drivers/scsi/lpfc/lpfc_init.o | 219760 - 219616 (-144 bytes)

 drivers/scsi/lpfc/lpfc_init.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/lpfc/lpfc_init.c2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/lpfc/lpfc_init.c2007-07-31 
11:07:59.0 +0200
@@ -1280,11 +1280,10 @@ lpfc_hba_init(struct lpfc_hba *phba, uin
uint32_t *HashWorking;
uint32_t *pwwnn = (uint32_t *) phba-wwnn;

-   HashWorking = kmalloc(80 * sizeof(uint32_t), GFP_KERNEL);
+   HashWorking = kcalloc(80, sizeof(uint32_t), GFP_KERNEL);
if (!HashWorking)
return;

-   memset(HashWorking, 0, (80 * sizeof(uint32_t)));
HashWorking[0] = HashWorking[78] = *pwwnn++;
HashWorking[1] = HashWorking[79] = *pwwnn;

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


[PATCH 46] drivers/scsi/lpfc/lpfc_scsi.c: kmalloc + memset conversion to kzalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/lpfc/lpfc_scsi.c | 42769 - 42721 (-48 bytes)
 drivers/scsi/lpfc/lpfc_scsi.o | 191332 - 191240 (-92 bytes)

 drivers/scsi/lpfc/lpfc_scsi.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/lpfc/lpfc_scsi.c2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/lpfc/lpfc_scsi.c2007-07-31 
11:08:46.0 +0200
@@ -208,10 +208,9 @@ lpfc_new_scsi_buf(struct lpfc_vport *vpo
dma_addr_t pdma_phys;
uint16_t iotag;

-   psb = kmalloc(sizeof(struct lpfc_scsi_buf), GFP_KERNEL);
+   psb = kzalloc(sizeof(struct lpfc_scsi_buf), GFP_KERNEL);
if (!psb)
return NULL;
-   memset(psb, 0, sizeof (struct lpfc_scsi_buf));

/*
 * Get memory from the pci pool to map the virt space to pci bus space
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 47] drivers/scsi/megaraid.c: kmalloc + memset conversion to kzalloc

2007-07-31 Thread Mariusz Kozlowski
This patch does kmalloc + memset conversion to kzalloc and adds missing check 
for
kzaloc return value.

Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/megaraid.c | 116109 - 116094 (-15 bytes)
 drivers/scsi/megaraid.o | 257872 - 257772 (-100 bytes)

 drivers/scsi/megaraid.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/megaraid.c  2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/megaraid.c  2007-07-31 
11:11:58.0 +0200
@@ -4408,8 +4408,10 @@ mega_internal_command(adapter_t *adapter
scmd = adapter-int_scmd;
memset(scmd, 0, sizeof(Scsi_Cmnd));

-   sdev = kmalloc(sizeof(struct scsi_device), GFP_KERNEL);
-   memset(sdev, 0, sizeof(struct scsi_device));
+   sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
+   if (!sdev)
+   return -ENOMEM;
+
scmd-device = sdev;

scmd-device-host = adapter-host;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 50] drivers/message/fusion/mptctl.c: mostly kmalloc + memset conversion to kzalloc

2007-07-31 Thread Mariusz Kozlowski
This patch does kmalloc + memset conversion to kzalloc and simplifies 
mptctl_probe().

Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/message/fusion/mptctl.c | 82092 - 81884 (-208 bytes)
 drivers/message/fusion/mptctl.o | 201784 - 200648 (-1136 bytes)

 drivers/message/fusion/mptctl.c |   36 ++
 1 file changed, 12 insertions(+), 24 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/message/fusion/mptctl.c  2007-07-26 
13:07:44.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/message/fusion/mptctl.c  2007-07-31 
18:02:38.0 +0200
@@ -963,10 +963,9 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, i
 * structures for the SG elements.
 */
i = MAX_SGL_BYTES / 8;
-   buflist = kmalloc(i, GFP_USER);
-   if (buflist == NULL)
+   buflist = kzalloc(i, GFP_USER);
+   if (!buflist)
return NULL;
-   memset(buflist, 0, i);
buflist_ent = 0;

/* Allocate a single block of memory to store the sg elements and
@@ -1363,13 +1362,12 @@ mptctl_gettargetinfo (unsigned long arg)
 *  15- 8: Bus Number
 *   7- 0: Target ID
 */
-   pmem = kmalloc(numBytes, GFP_KERNEL);
-   if (pmem == NULL) {
+   pmem = kzalloc(numBytes, GFP_KERNEL);
+   if (!pmem) {
printk(KERN_ERR %s::mptctl_gettargetinfo() @%d - no memory 
available!\n,
__FILE__, __LINE__);
return -ENOMEM;
}
-   memset(pmem, 0, numBytes);
pdata =  (int *) pmem;

/* Get number of devices
@@ -1551,12 +1549,11 @@ mptctl_eventenable (unsigned long arg)
/* Have not yet allocated memory - do so now.
 */
int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS);
-   ioc-events = kmalloc(sz, GFP_KERNEL);
-   if (ioc-events == NULL) {
+   ioc-events = kzalloc(sz, GFP_KERNEL);
+   if (!ioc-events) {
printk(KERN_ERR MYNAM : ERROR - Insufficient memory to 
add adapter!\n);
return -ENOMEM;
}
-   memset(ioc-events, 0, sz);
ioc-alloc_total += sz;

ioc-eventContext = 0;
@@ -2823,31 +2820,22 @@ static long compat_mpctl_ioctl(struct fi
 static int
 mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
-   int err;
-   int sz;
-   u8 *mem;
+   MPT_IOCTL *mem;
MPT_ADAPTER *ioc = pci_get_drvdata(pdev);

/*
 * Allocate and inite a MPT_IOCTL structure
*/
-   sz = sizeof (MPT_IOCTL);
-   mem = kmalloc(sz, GFP_KERNEL);
-   if (mem == NULL) {
-   err = -ENOMEM;
-   goto out_fail;
+   mem = kzalloc(sizeof(MPT_IOCTL), GFP_KERNEL);
+   if (!mem) {
+   mptctl_remove(pdev);
+   return -ENOMEM;
}

-   memset(mem, 0, sz);
-   ioc-ioctl = (MPT_IOCTL *) mem;
+   ioc-ioctl = mem;
ioc-ioctl-ioc = ioc;
mutex_init(ioc-ioctl-ioctl_mutex);
return 0;
-
-out_fail:
-
-   mptctl_remove(pdev);
-   return err;
 }

 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 54] drivers/scsi/mvme16x_scsi.c: kmalloc + memset conversion to kzalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/mvme16x_scsi.c | 3740 - 3678 (-62 bytes)

 drivers/scsi/mvme16x_scsi.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/mvme16x_scsi.c  2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/mvme16x_scsi.c  2007-07-31 
11:02:11.0 +0200
@@ -48,13 +48,12 @@ mvme16x_probe(struct device *dev)
goto out;
}

-   hostdata = kmalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
+   hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
if (hostdata == NULL) {
printk(KERN_ERR mvme16x-scsi: 
Failed to allocate host data\n);
goto out;
}
-   memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));

/* Fill in the required pieces of hostdata */
hostdata-base = (void __iomem *)0xfff47000UL;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 56] drivers/scsi/NCR_D700.c: kmalloc + memset conversion to kzalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/NCR_D700.c | 10643 - 10615 (-28 bytes)
 drivers/scsi/NCR_D700.o | 118400 - 118196 (-204 bytes)

 drivers/scsi/NCR_D700.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/NCR_D700.c  2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/NCR_D700.c  2007-07-31 
11:13:37.0 +0200
@@ -313,10 +313,10 @@ NCR_D700_probe(struct device *dev)
break;
}

-   p = kmalloc(sizeof(*p), GFP_KERNEL);
+   p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p)
return -ENOMEM;
-   memset(p, '\0', sizeof(*p));
+
p-dev = dev;
snprintf(p-name, sizeof(p-name), D700(%s), dev-bus_id);
if (request_irq(irq, NCR_D700_intr, IRQF_SHARED, p-name, p)) {
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 61] drivers/scsi/osst.c: kmalloc + memset conversion to kzalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/osst.c | 185412 - 185361 (-51 bytes)
 drivers/scsi/osst.o | 272432 - 272344 (-88 bytes)

 drivers/scsi/osst.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/osst.c  2007-07-26 13:07:42.0 
+0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/osst.c  2007-07-31 14:14:52.0 
+0200
@@ -5778,13 +5778,12 @@ static int osst_probe(struct device *dev
dev_num = i;

/* allocate a struct osst_tape for this device */
-   tpnt = kmalloc(sizeof(struct osst_tape), GFP_ATOMIC);
-   if (tpnt == NULL) {
+   tpnt = kzalloc(sizeof(struct osst_tape), GFP_ATOMIC);
+   if (!tpnt) {
write_unlock(os_scsi_tapes_lock);
printk(KERN_ERR osst :E: Can't allocate device descriptor, 
device not attached.\n);
goto out_put_disk;
}
-   memset(tpnt, 0, sizeof(struct osst_tape));

/* allocate a buffer for this device */
i = SDp-host-sg_tablesize;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 63] drivers/scsi/pluto.c: mostly kmalloc + memset conversion to kcalloc

2007-07-31 Thread Mariusz Kozlowski
This patch does kmalloc + memset conversion to kcalloc. Also the following 
warning is fixed.

  CC  drivers/scsi/pluto.o
  drivers/scsi/pluto.c: In function 'pluto_info':
  drivers/scsi/pluto.c:283: warning: unused variable 'p'

Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/pluto.c | 8787 - 8657 (-130 bytes)
 drivers/scsi/pluto.o | 125264 - 124648 (-616 bytes)

 drivers/scsi/pluto.c |   24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/pluto.c 2007-07-26 13:07:42.0 
+0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/pluto.c 2007-07-31 18:18:38.0 
+0200
@@ -111,13 +111,12 @@ int __init pluto_detect(struct scsi_host
 #endif
return 0;
}
-   fcs = kmalloc(sizeof (struct ctrl_inquiry) * fcscount, GFP_DMA);
+   fcs = kcalloc(fcscount, sizeof(struct ctrl_inquiry), GFP_DMA);
if (!fcs) {
printk (PLUTO: Not enough memory to probe\n);
return 0;
}

-   memset (fcs, 0, sizeof (struct ctrl_inquiry) * fcscount);
memset (dev, 0, sizeof(dev));
atomic_set (fcss, fcscount);

@@ -211,12 +210,12 @@ int __init pluto_detect(struct scsi_host
char *p;
long *ages;

-   ages = kmalloc (((inq-channels + 1) * 
inq-targets) * sizeof(long), GFP_KERNEL);
-   if (!ages) continue;
+   ages = kcalloc((inq-channels + 1) * 
inq-targets, sizeof(long), GFP_KERNEL);
+   if (!ages)
+   continue;

host = scsi_register (tpnt, sizeof (struct 
pluto));
-   if(!host)
-   {
+   if (!host) {
kfree(ages);
continue;
}
@@ -238,7 +237,6 @@ int __init pluto_detect(struct scsi_host
fc-channels = inq-channels + 1;
fc-targets = inq-targets;
fc-ages = ages;
-   memset (ages, 0, ((inq-channels + 1) * 
inq-targets) * sizeof(long));

pluto-fc = fc;
memcpy (pluto-rev_str, inq-revision, 4);
@@ -260,7 +258,7 @@ int __init pluto_detect(struct scsi_host
} else
fc-fcp_register(fc, TYPE_SCSI_FCP, 1);
}
-   kfree((char *)fcs);
+   kfree(fcs);
if (nplutos)
printk (PLUTO: Total of %d SparcSTORAGE Arrays found\n, 
nplutos);
return nplutos;
@@ -282,15 +280,19 @@ int pluto_release(struct Scsi_Host *host

 const char *pluto_info(struct Scsi_Host *host)
 {
-   static char buf[128], *p;
+   static char buf[128];
struct pluto *pluto = (struct pluto *) host-hostdata;

sprintf(buf, SUN SparcSTORAGE Array %s fw %s serial %s %dx%d on %s,
pluto-rev_str, pluto-fw_rev_str, pluto-serial_str,
host-max_channel, host-max_id, pluto-fc-name);
 #ifdef __sparc__
-   p = strchr(buf, 0);
-   sprintf(p,  PROM node %x, pluto-fc-dev-prom_node);
+   {
+   char *p;
+
+   p = strchr(buf, 0);
+   sprintf(p,  PROM node %x, pluto-fc-dev-prom_node);
+   }
 #endif
return buf;
 }
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 64] drivers/scsi/qla2xxx/qla_init.c: mostly kmalloc + memset conversion to k[cz]alloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/qla2xxx/qla_init.c | 107445 - 107327 (-118 bytes)
 drivers/scsi/qla2xxx/qla_init.o | 237540 - 237424 (-116 bytes)

 drivers/scsi/qla2xxx/qla_init.c |   14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/qla2xxx/qla_init.c  2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/qla2xxx/qla_init.c  2007-07-31 
14:24:51.0 +0200
@@ -1787,12 +1787,11 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha
 {
fc_port_t *fcport;

-   fcport = kmalloc(sizeof(fc_port_t), flags);
-   if (fcport == NULL)
-   return (fcport);
+   fcport = kzalloc(sizeof(fc_port_t), flags);
+   if (!fcport)
+   return NULL;

/* Setup fcport template structure. */
-   memset(fcport, 0, sizeof (fc_port_t));
fcport-ha = ha;
fcport-vp_idx = ha-vp_idx;
fcport-port_type = FCT_UNKNOWN;
@@ -1802,7 +1801,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha
fcport-supported_classes = FC_COS_UNSPECIFIED;
spin_lock_init(fcport-rport_lock);

-   return (fcport);
+   return fcport;
 }

 /*
@@ -2497,13 +2496,12 @@ qla2x00_find_all_fabric_devs(scsi_qla_ho
rval = QLA_SUCCESS;

/* Try GID_PT to get device list, else GAN. */
-   swl = kmalloc(sizeof(sw_info_t) * MAX_FIBRE_DEVICES, GFP_ATOMIC);
-   if (swl == NULL) {
+   swl = kcalloc(MAX_FIBRE_DEVICES, sizeof(sw_info_t), GFP_ATOMIC);
+   if (!swl) {
/*EMPTY*/
DEBUG2(printk(scsi(%ld): GID_PT allocations failed, fallback 
on GA_NXT\n, ha-host_no));
} else {
-   memset(swl, 0, sizeof(sw_info_t) * MAX_FIBRE_DEVICES);
if (qla2x00_gid_pt(ha, swl) != QLA_SUCCESS) {
kfree(swl);
swl = NULL;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 82] drivers/scsi/zorro7xx.c: kmalloc + memset conversion to kzalloc

2007-07-31 Thread Mariusz Kozlowski
Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/zorro7xx.c | 4579 - 4501 (-78 bytes)

 drivers/scsi/zorro7xx.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

--- linux-2.6.23-rc1-mm1-a/drivers/scsi/zorro7xx.c  2007-07-26 
13:07:42.0 +0200
+++ linux-2.6.23-rc1-mm1-b/drivers/scsi/zorro7xx.c  2007-07-31 
14:25:58.0 +0200
@@ -69,7 +69,7 @@ static struct zorro_device_id zorro7xx_z
 static int __devinit zorro7xx_init_one(struct zorro_dev *z,
   const struct zorro_device_id *ent)
 {
-   struct Scsi_Host * host = NULL;
+   struct Scsi_Host *host;
struct NCR_700_Host_Parameters *hostdata;
struct zorro_driver_data *zdd;
unsigned long board, ioaddr;
@@ -89,14 +89,12 @@ static int __devinit zorro7xx_init_one(s
return -EBUSY;
}

-   hostdata = kmalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
-   if (hostdata == NULL) {
+   hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
+   if (!hostdata) {
printk(KERN_ERR zorro7xx: Failed to allocate host data\n);
goto out_release;
}

-   memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));
-
/* Fill in the required pieces of hostdata */
if (ioaddr  0x0100)
hostdata-base = ioremap(ioaddr, zorro_resource_len(z));
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: lpfc error path fix

2007-01-01 Thread Mariusz Kozlowski
Hello,

Add kmalloc failure check and fix the loop on error path. Without the
patch pool element at index [0] will not be freed.

Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/lpfc/lpfc_mem.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff -upr linux-2.6.20-rc2-mm1-a/drivers/scsi/lpfc/lpfc_mem.c 
linux-2.6.20-rc2-mm1-b/drivers/scsi/lpfc/lpfc_mem.c
--- linux-2.6.20-rc2-mm1-a/drivers/scsi/lpfc/lpfc_mem.c 2006-12-24 
05:00:32.0 +0100
+++ linux-2.6.20-rc2-mm1-b/drivers/scsi/lpfc/lpfc_mem.c 2007-01-02 
00:17:25.0 +0100
@@ -56,6 +56,9 @@ lpfc_mem_alloc(struct lpfc_hba * phba)
 
pool-elements = kmalloc(sizeof(struct lpfc_dmabuf) *
 LPFC_MBUF_POOL_SIZE, GFP_KERNEL);
+   if (!pool-elements)
+   goto fail_free_lpfc_mbuf_pool;
+
pool-max_count = 0;
pool-current_count = 0;
for ( i = 0; i  LPFC_MBUF_POOL_SIZE; i++) {
@@ -82,10 +85,11 @@ lpfc_mem_alloc(struct lpfc_hba * phba)
  fail_free_mbox_pool:
mempool_destroy(phba-mbox_mem_pool);
  fail_free_mbuf_pool:
-   while (--i)
+   while (i--)
pci_pool_free(phba-lpfc_mbuf_pool, pool-elements[i].virt,
 pool-elements[i].phys);
kfree(pool-elements);
+ fail_free_lpfc_mbuf_pool:
pci_pool_destroy(phba-lpfc_mbuf_pool);
  fail_free_dma_buf_pool:
pci_pool_destroy(phba-lpfc_scsi_dma_buf_pool);


-- 
Regards,

Mariusz Kozlowski
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[2.4 PATCH] scsi 53c7xx parenthesis fix

2006-12-04 Thread Mariusz Kozlowski
Hello,

Tis patch removes an extra parenthesis in abort_connected() code.

Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

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

--- linux-2.4.34-pre6-a/drivers/scsi/53c7xx.c   2004-02-18 14:36:31.0 
+0100
+++ linux-2.4.34-pre6-b/drivers/scsi/53c7xx.c   2006-12-01 12:22:28.0 
+0100
@@ -4409,7 +4409,7 @@ abort_connected (struct Scsi_Host *host)
  * account the current synchronous offset) 
  */
 
-sstat = (NCR53c8x0_read8 (SSTAT2_REG);
+sstat = NCR53c8x0_read8 (SSTAT2_REG);
 offset = OFFSET (sstat  SSTAT2_FF_MASK)  SSTAT2_FF_SHIFT;
 phase = sstat  SSTAT2_PHASE_MASK;
 

-- 
Regards,

Mariusz Kozlowski
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[2.4 PATCH] scsi 53c7,8xx parenthesis fix

2006-12-04 Thread Mariusz Kozlowski
Hello,

This patch removes an extra parenthesis in debugger_fn_bs() code.

Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/53c7,8xx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.4.34-pre6-a/drivers/scsi/53c7,8xx.c 2004-11-17 12:54:21.0 
+0100
+++ linux-2.4.34-pre6-b/drivers/scsi/53c7,8xx.c 2006-12-01 12:21:50.0 
+0100
@@ -3197,7 +3197,7 @@ debugger_fn_bs (struct Scsi_Host *host, 
 
 bp-address = (u32 *) args[0];
 memcpy ((void *) bp-old_instruction, (void *) bp-address, 8);
-bp-old_size = (((bp-old_instruction[0]  24)  DCMD_TYPE_MASK) ==
+bp-old_size = ((bp-old_instruction[0]  24)  DCMD_TYPE_MASK) ==
DCMD_TYPE_MMI ? 3 : 2;
 bp-next = hostdata-breakpoints;
 hostdata-breakpoints = bp-next;


-- 
Regards,

Mariusz Kozlowski
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: 53c7xx brackets fix

2006-11-30 Thread Mariusz Kozlowski
Hello,

This patch fixes brackets in two places.

Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED]

 drivers/scsi/53c7xx.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux-2.6.19-rc6-mm2-a/drivers/scsi/53c7xx.c2006-11-16 
05:03:40.0 +0100
+++ linux-2.6.19-rc6-mm2-b/drivers/scsi/53c7xx.c2006-11-29 
15:50:54.0 +0100
@@ -4400,7 +4400,7 @@ abort_connected (struct Scsi_Host *host)
  * account the current synchronous offset) 
  */
 
-sstat = (NCR53c8x0_read8 (SSTAT2_REG);
+sstat = NCR53c8x0_read8 (SSTAT2_REG);
 offset = OFFSET (sstat  SSTAT2_FF_MASK)  SSTAT2_FF_SHIFT;
 phase = sstat  SSTAT2_PHASE_MASK;
 
@@ -5423,7 +5423,7 @@ insn_to_offset (Scsi_Cmnd *cmd, u32 *ins
 --buffers, offset += segment-length, ++segment)
 #if 0
printk(scsi%d: comparing 0x%p to 0x%p\n, 
-   cmd-device-host-host_no, saved, 
page_address(segment-page+segment-offset);
+   cmd-device-host-host_no, saved, 
page_address(segment-page+segment-offset));
 #else
;
 #endif


-- 
Regards,

Mariusz Kozlowski
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html