aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJes Sorensen <jes@sgi.com>2006-01-16 10:31:18 -0500
committer <jejb@mulgrave.il.steeleye.com>2006-02-27 23:55:02 -0500
commit24669f75a3231fa37444977c92d1f4838bec1233 (patch)
tree3b64076b7d031aa31b95caeb512fb7e68b5fd28f /drivers
parentb9a33cebac70d6f67a769ce8d4078fee2b254ada (diff)
[SCSI] SCSI core kmalloc2kzalloc
Change the core SCSI code to use kzalloc rather than kmalloc+memset where possible. Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/hosts.c3
-rw-r--r--drivers/scsi/scsi.c3
-rw-r--r--drivers/scsi/scsi_debug.c9
-rw-r--r--drivers/scsi/scsi_ioctl.c3
-rw-r--r--drivers/scsi/scsi_lib.c5
-rw-r--r--drivers/scsi/scsi_scan.c6
-rw-r--r--drivers/scsi/scsi_transport_fc.c9
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c3
-rw-r--r--drivers/scsi/scsi_transport_sas.c9
-rw-r--r--drivers/scsi/scsi_transport_spi.c12
-rw-r--r--drivers/scsi/sd.c3
-rw-r--r--drivers/scsi/sg.c6
-rw-r--r--drivers/scsi/sr.c3
-rw-r--r--drivers/scsi/sr_ioctl.c6
-rw-r--r--drivers/scsi/st.c9
15 files changed, 30 insertions, 59 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 588107923499..ef57f253031c 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -306,10 +306,9 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
306 dump_stack(); 306 dump_stack();
307 } 307 }
308 308
309 shost = kmalloc(sizeof(struct Scsi_Host) + privsize, gfp_mask); 309 shost = kzalloc(sizeof(struct Scsi_Host) + privsize, gfp_mask);
310 if (!shost) 310 if (!shost)
311 return NULL; 311 return NULL;
312 memset(shost, 0, sizeof(struct Scsi_Host) + privsize);
313 312
314 spin_lock_init(&shost->default_lock); 313 spin_lock_init(&shost->default_lock);
315 scsi_assign_lock(shost, &shost->default_lock); 314 scsi_assign_lock(shost, &shost->default_lock);
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index c551bb84dbfb..11b27ba0cd41 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -136,9 +136,8 @@ struct scsi_request *scsi_allocate_request(struct scsi_device *sdev,
136 const int size = offset + sizeof(struct request); 136 const int size = offset + sizeof(struct request);
137 struct scsi_request *sreq; 137 struct scsi_request *sreq;
138 138
139 sreq = kmalloc(size, gfp_mask); 139 sreq = kzalloc(size, gfp_mask);
140 if (likely(sreq != NULL)) { 140 if (likely(sreq != NULL)) {
141 memset(sreq, 0, size);
142 sreq->sr_request = (struct request *)(((char *)sreq) + offset); 141 sreq->sr_request = (struct request *)(((char *)sreq) + offset);
143 sreq->sr_device = sdev; 142 sreq->sr_device = sdev;
144 sreq->sr_host = sdev->host; 143 sreq->sr_host = sdev->host;
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 0e529f8171c4..5a5d2af8ee43 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -1061,13 +1061,12 @@ static struct sdebug_dev_info * devInfoReg(struct scsi_device * sdev)
1061 } 1061 }
1062 } 1062 }
1063 if (NULL == open_devip) { /* try and make a new one */ 1063 if (NULL == open_devip) { /* try and make a new one */
1064 open_devip = kmalloc(sizeof(*open_devip),GFP_KERNEL); 1064 open_devip = kzalloc(sizeof(*open_devip),GFP_KERNEL);
1065 if (NULL == open_devip) { 1065 if (NULL == open_devip) {
1066 printk(KERN_ERR "%s: out of memory at line %d\n", 1066 printk(KERN_ERR "%s: out of memory at line %d\n",
1067 __FUNCTION__, __LINE__); 1067 __FUNCTION__, __LINE__);
1068 return NULL; 1068 return NULL;
1069 } 1069 }
1070 memset(open_devip, 0, sizeof(*open_devip));
1071 open_devip->sdbg_host = sdbg_host; 1070 open_devip->sdbg_host = sdbg_host;
1072 list_add_tail(&open_devip->dev_list, 1071 list_add_tail(&open_devip->dev_list,
1073 &sdbg_host->dev_info_list); 1072 &sdbg_host->dev_info_list);
@@ -1814,7 +1813,7 @@ static int sdebug_add_adapter(void)
1814 struct sdebug_dev_info *sdbg_devinfo; 1813 struct sdebug_dev_info *sdbg_devinfo;
1815 struct list_head *lh, *lh_sf; 1814 struct list_head *lh, *lh_sf;
1816 1815
1817 sdbg_host = kmalloc(sizeof(*sdbg_host),GFP_KERNEL); 1816 sdbg_host = kzalloc(sizeof(*sdbg_host), GFP_KERNEL);
1818 1817
1819 if (NULL == sdbg_host) { 1818 if (NULL == sdbg_host) {
1820 printk(KERN_ERR "%s: out of memory at line %d\n", 1819 printk(KERN_ERR "%s: out of memory at line %d\n",
@@ -1822,19 +1821,17 @@ static int sdebug_add_adapter(void)
1822 return -ENOMEM; 1821 return -ENOMEM;
1823 } 1822 }
1824 1823
1825 memset(sdbg_host, 0, sizeof(*sdbg_host));
1826 INIT_LIST_HEAD(&sdbg_host->dev_info_list); 1824 INIT_LIST_HEAD(&sdbg_host->dev_info_list);
1827 1825
1828 devs_per_host = scsi_debug_num_tgts * scsi_debug_max_luns; 1826 devs_per_host = scsi_debug_num_tgts * scsi_debug_max_luns;
1829 for (k = 0; k < devs_per_host; k++) { 1827 for (k = 0; k < devs_per_host; k++) {
1830 sdbg_devinfo = kmalloc(sizeof(*sdbg_devinfo),GFP_KERNEL); 1828 sdbg_devinfo = kzalloc(sizeof(*sdbg_devinfo), GFP_KERNEL);
1831 if (NULL == sdbg_devinfo) { 1829 if (NULL == sdbg_devinfo) {
1832 printk(KERN_ERR "%s: out of memory at line %d\n", 1830 printk(KERN_ERR "%s: out of memory at line %d\n",
1833 __FUNCTION__, __LINE__); 1831 __FUNCTION__, __LINE__);
1834 error = -ENOMEM; 1832 error = -ENOMEM;
1835 goto clean; 1833 goto clean;
1836 } 1834 }
1837 memset(sdbg_devinfo, 0, sizeof(*sdbg_devinfo));
1838 sdbg_devinfo->sdbg_host = sdbg_host; 1835 sdbg_devinfo->sdbg_host = sdbg_host;
1839 list_add_tail(&sdbg_devinfo->dev_list, 1836 list_add_tail(&sdbg_devinfo->dev_list,
1840 &sdbg_host->dev_info_list); 1837 &sdbg_host->dev_info_list);
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 0bba7d8eebb0..36e930066649 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -241,10 +241,9 @@ int scsi_ioctl_send_command(struct scsi_device *sdev,
241 buf_needed = (buf_needed + 511) & ~511; 241 buf_needed = (buf_needed + 511) & ~511;
242 if (buf_needed > MAX_BUF) 242 if (buf_needed > MAX_BUF)
243 buf_needed = MAX_BUF; 243 buf_needed = MAX_BUF;
244 buf = kmalloc(buf_needed, gfp_mask); 244 buf = kzalloc(buf_needed, gfp_mask);
245 if (!buf) 245 if (!buf)
246 return -ENOMEM; 246 return -ENOMEM;
247 memset(buf, 0, buf_needed);
248 if (inlen == 0) { 247 if (inlen == 0) {
249 data_direction = DMA_FROM_DEVICE; 248 data_direction = DMA_FROM_DEVICE;
250 } else if (outlen == 0 ) { 249 } else if (outlen == 0 ) {
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 4362dcde74af..1fe4fd83e305 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -286,13 +286,12 @@ int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd,
286 int result; 286 int result;
287 287
288 if (sshdr) { 288 if (sshdr) {
289 sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_NOIO); 289 sense = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_NOIO);
290 if (!sense) 290 if (!sense)
291 return DRIVER_ERROR << 24; 291 return DRIVER_ERROR << 24;
292 memset(sense, 0, SCSI_SENSE_BUFFERSIZE);
293 } 292 }
294 result = scsi_execute(sdev, cmd, data_direction, buffer, bufflen, 293 result = scsi_execute(sdev, cmd, data_direction, buffer, bufflen,
295 sense, timeout, retries, 0); 294 sense, timeout, retries, 0);
296 if (sshdr) 295 if (sshdr)
297 scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, sshdr); 296 scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, sshdr);
298 297
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 5acb83ca5ae5..74863da1d630 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -205,12 +205,11 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
205 int display_failure_msg = 1, ret; 205 int display_failure_msg = 1, ret;
206 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 206 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
207 207
208 sdev = kmalloc(sizeof(*sdev) + shost->transportt->device_size, 208 sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size,
209 GFP_ATOMIC); 209 GFP_ATOMIC);
210 if (!sdev) 210 if (!sdev)
211 goto out; 211 goto out;
212 212
213 memset(sdev, 0, sizeof(*sdev));
214 sdev->vendor = scsi_null_device_strs; 213 sdev->vendor = scsi_null_device_strs;
215 sdev->model = scsi_null_device_strs; 214 sdev->model = scsi_null_device_strs;
216 sdev->rev = scsi_null_device_strs; 215 sdev->rev = scsi_null_device_strs;
@@ -334,12 +333,11 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
334 struct scsi_target *starget; 333 struct scsi_target *starget;
335 struct scsi_target *found_target; 334 struct scsi_target *found_target;
336 335
337 starget = kmalloc(size, GFP_KERNEL); 336 starget = kzalloc(size, GFP_KERNEL);
338 if (!starget) { 337 if (!starget) {
339 printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); 338 printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__);
340 return NULL; 339 return NULL;
341 } 340 }
342 memset(starget, 0, size);
343 dev = &starget->dev; 341 dev = &starget->dev;
344 device_initialize(dev); 342 device_initialize(dev);
345 starget->reap_ref = 1; 343 starget->reap_ref = 1;
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index f2c9acf11bd0..56012b2694d2 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -1115,15 +1115,13 @@ static int fc_user_scan(struct Scsi_Host *shost, uint channel,
1115struct scsi_transport_template * 1115struct scsi_transport_template *
1116fc_attach_transport(struct fc_function_template *ft) 1116fc_attach_transport(struct fc_function_template *ft)
1117{ 1117{
1118 struct fc_internal *i = kmalloc(sizeof(struct fc_internal),
1119 GFP_KERNEL);
1120 int count; 1118 int count;
1119 struct fc_internal *i = kzalloc(sizeof(struct fc_internal),
1120 GFP_KERNEL);
1121 1121
1122 if (unlikely(!i)) 1122 if (unlikely(!i))
1123 return NULL; 1123 return NULL;
1124 1124
1125 memset(i, 0, sizeof(struct fc_internal));
1126
1127 i->t.target_attrs.ac.attrs = &i->starget_attrs[0]; 1125 i->t.target_attrs.ac.attrs = &i->starget_attrs[0];
1128 i->t.target_attrs.ac.class = &fc_transport_class.class; 1126 i->t.target_attrs.ac.class = &fc_transport_class.class;
1129 i->t.target_attrs.ac.match = fc_target_match; 1127 i->t.target_attrs.ac.match = fc_target_match;
@@ -1305,12 +1303,11 @@ fc_rport_create(struct Scsi_Host *shost, int channel,
1305 size_t size; 1303 size_t size;
1306 1304
1307 size = (sizeof(struct fc_rport) + fci->f->dd_fcrport_size); 1305 size = (sizeof(struct fc_rport) + fci->f->dd_fcrport_size);
1308 rport = kmalloc(size, GFP_KERNEL); 1306 rport = kzalloc(size, GFP_KERNEL);
1309 if (unlikely(!rport)) { 1307 if (unlikely(!rport)) {
1310 printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__); 1308 printk(KERN_ERR "%s: allocation failure\n", __FUNCTION__);
1311 return NULL; 1309 return NULL;
1312 } 1310 }
1313 memset(rport, 0, size);
1314 1311
1315 rport->maxframe_size = -1; 1312 rport->maxframe_size = -1;
1316 rport->supported_classes = FC_COS_UNSPECIFIED; 1313 rport->supported_classes = FC_COS_UNSPECIFIED;
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 71e54a64adca..2730d507e585 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -1117,10 +1117,9 @@ iscsi_register_transport(struct iscsi_transport *tt)
1117 if (priv) 1117 if (priv)
1118 return NULL; 1118 return NULL;
1119 1119
1120 priv = kmalloc(sizeof(*priv), GFP_KERNEL); 1120 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
1121 if (!priv) 1121 if (!priv)
1122 return NULL; 1122 return NULL;
1123 memset(priv, 0, sizeof(*priv));
1124 INIT_LIST_HEAD(&priv->list); 1123 INIT_LIST_HEAD(&priv->list);
1125 priv->iscsi_transport = tt; 1124 priv->iscsi_transport = tt;
1126 1125
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index 210dab5879fa..205542988e29 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -391,10 +391,9 @@ struct sas_phy *sas_phy_alloc(struct device *parent, int number)
391 struct Scsi_Host *shost = dev_to_shost(parent); 391 struct Scsi_Host *shost = dev_to_shost(parent);
392 struct sas_phy *phy; 392 struct sas_phy *phy;
393 393
394 phy = kmalloc(sizeof(*phy), GFP_KERNEL); 394 phy = kzalloc(sizeof(*phy), GFP_KERNEL);
395 if (!phy) 395 if (!phy)
396 return NULL; 396 return NULL;
397 memset(phy, 0, sizeof(*phy));
398 397
399 get_device(parent); 398 get_device(parent);
400 399
@@ -585,12 +584,11 @@ struct sas_rphy *sas_rphy_alloc(struct sas_phy *parent)
585 struct Scsi_Host *shost = dev_to_shost(&parent->dev); 584 struct Scsi_Host *shost = dev_to_shost(&parent->dev);
586 struct sas_rphy *rphy; 585 struct sas_rphy *rphy;
587 586
588 rphy = kmalloc(sizeof(*rphy), GFP_KERNEL); 587 rphy = kzalloc(sizeof(*rphy), GFP_KERNEL);
589 if (!rphy) { 588 if (!rphy) {
590 put_device(&parent->dev); 589 put_device(&parent->dev);
591 return NULL; 590 return NULL;
592 } 591 }
593 memset(rphy, 0, sizeof(*rphy));
594 592
595 device_initialize(&rphy->dev); 593 device_initialize(&rphy->dev);
596 rphy->dev.parent = get_device(&parent->dev); 594 rphy->dev.parent = get_device(&parent->dev);
@@ -793,10 +791,9 @@ sas_attach_transport(struct sas_function_template *ft)
793 struct sas_internal *i; 791 struct sas_internal *i;
794 int count; 792 int count;
795 793
796 i = kmalloc(sizeof(struct sas_internal), GFP_KERNEL); 794 i = kzalloc(sizeof(struct sas_internal), GFP_KERNEL);
797 if (!i) 795 if (!i)
798 return NULL; 796 return NULL;
799 memset(i, 0, sizeof(struct sas_internal));
800 797
801 i->t.user_scan = sas_user_scan; 798 i->t.user_scan = sas_user_scan;
802 799
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 7ee95eb83dda..a1e521b58b67 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -900,13 +900,11 @@ spi_dv_device(struct scsi_device *sdev)
900 if (unlikely(scsi_device_get(sdev))) 900 if (unlikely(scsi_device_get(sdev)))
901 return; 901 return;
902 902
903 buffer = kmalloc(len, GFP_KERNEL); 903 buffer = kzalloc(len, GFP_KERNEL);
904 904
905 if (unlikely(!buffer)) 905 if (unlikely(!buffer))
906 goto out_put; 906 goto out_put;
907 907
908 memset(buffer, 0, len);
909
910 /* We need to verify that the actual device will quiesce; the 908 /* We need to verify that the actual device will quiesce; the
911 * later target quiesce is just a nice to have */ 909 * later target quiesce is just a nice to have */
912 if (unlikely(scsi_device_quiesce(sdev))) 910 if (unlikely(scsi_device_quiesce(sdev)))
@@ -1265,15 +1263,13 @@ static DECLARE_ANON_TRANSPORT_CLASS(spi_device_class,
1265struct scsi_transport_template * 1263struct scsi_transport_template *
1266spi_attach_transport(struct spi_function_template *ft) 1264spi_attach_transport(struct spi_function_template *ft)
1267{ 1265{
1268 struct spi_internal *i = kmalloc(sizeof(struct spi_internal),
1269 GFP_KERNEL);
1270 int count = 0; 1266 int count = 0;
1267 struct spi_internal *i = kzalloc(sizeof(struct spi_internal),
1268 GFP_KERNEL);
1269
1271 if (unlikely(!i)) 1270 if (unlikely(!i))
1272 return NULL; 1271 return NULL;
1273 1272
1274 memset(i, 0, sizeof(struct spi_internal));
1275
1276
1277 i->t.target_attrs.ac.class = &spi_transport_class.class; 1273 i->t.target_attrs.ac.class = &spi_transport_class.class;
1278 i->t.target_attrs.ac.attrs = &i->attrs[0]; 1274 i->t.target_attrs.ac.attrs = &i->attrs[0];
1279 i->t.target_attrs.ac.match = spi_target_match; 1275 i->t.target_attrs.ac.match = spi_target_match;
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 9d9872347f56..8ba2d988d051 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1517,11 +1517,10 @@ static int sd_probe(struct device *dev)
1517 "sd_attach\n")); 1517 "sd_attach\n"));
1518 1518
1519 error = -ENOMEM; 1519 error = -ENOMEM;
1520 sdkp = kmalloc(sizeof(*sdkp), GFP_KERNEL); 1520 sdkp = kzalloc(sizeof(*sdkp), GFP_KERNEL);
1521 if (!sdkp) 1521 if (!sdkp)
1522 goto out; 1522 goto out;
1523 1523
1524 memset (sdkp, 0, sizeof(*sdkp));
1525 kref_init(&sdkp->kref); 1524 kref_init(&sdkp->kref);
1526 1525
1527 gd = alloc_disk(16); 1526 gd = alloc_disk(16);
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 2a547538d444..ecf2f6010e76 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1361,7 +1361,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1361 void *old_sg_dev_arr = NULL; 1361 void *old_sg_dev_arr = NULL;
1362 int k, error; 1362 int k, error;
1363 1363
1364 sdp = kmalloc(sizeof(Sg_device), GFP_KERNEL); 1364 sdp = kzalloc(sizeof(Sg_device), GFP_KERNEL);
1365 if (!sdp) { 1365 if (!sdp) {
1366 printk(KERN_WARNING "kmalloc Sg_device failure\n"); 1366 printk(KERN_WARNING "kmalloc Sg_device failure\n");
1367 return -ENOMEM; 1367 return -ENOMEM;
@@ -1373,12 +1373,11 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1373 int tmp_dev_max = sg_nr_dev + SG_DEV_ARR_LUMP; 1373 int tmp_dev_max = sg_nr_dev + SG_DEV_ARR_LUMP;
1374 write_unlock_irqrestore(&sg_dev_arr_lock, iflags); 1374 write_unlock_irqrestore(&sg_dev_arr_lock, iflags);
1375 1375
1376 tmp_da = kmalloc(tmp_dev_max * sizeof(Sg_device *), GFP_KERNEL); 1376 tmp_da = kzalloc(tmp_dev_max * sizeof(Sg_device *), GFP_KERNEL);
1377 if (unlikely(!tmp_da)) 1377 if (unlikely(!tmp_da))
1378 goto expand_failed; 1378 goto expand_failed;
1379 1379
1380 write_lock_irqsave(&sg_dev_arr_lock, iflags); 1380 write_lock_irqsave(&sg_dev_arr_lock, iflags);
1381 memset(tmp_da, 0, tmp_dev_max * sizeof(Sg_device *));
1382 memcpy(tmp_da, sg_dev_arr, sg_dev_max * sizeof(Sg_device *)); 1381 memcpy(tmp_da, sg_dev_arr, sg_dev_max * sizeof(Sg_device *));
1383 old_sg_dev_arr = sg_dev_arr; 1382 old_sg_dev_arr = sg_dev_arr;
1384 sg_dev_arr = tmp_da; 1383 sg_dev_arr = tmp_da;
@@ -1391,7 +1390,6 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1391 if (unlikely(k >= SG_MAX_DEVS)) 1390 if (unlikely(k >= SG_MAX_DEVS))
1392 goto overflow; 1391 goto overflow;
1393 1392
1394 memset(sdp, 0, sizeof(*sdp));
1395 SCSI_LOG_TIMEOUT(3, printk("sg_alloc: dev=%d \n", k)); 1393 SCSI_LOG_TIMEOUT(3, printk("sg_alloc: dev=%d \n", k));
1396 sprintf(disk->disk_name, "sg%d", k); 1394 sprintf(disk->disk_name, "sg%d", k);
1397 disk->first_minor = k; 1395 disk->first_minor = k;
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 997f8e30509b..d8d12a1718bf 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -525,10 +525,9 @@ static int sr_probe(struct device *dev)
525 goto fail; 525 goto fail;
526 526
527 error = -ENOMEM; 527 error = -ENOMEM;
528 cd = kmalloc(sizeof(*cd), GFP_KERNEL); 528 cd = kzalloc(sizeof(*cd), GFP_KERNEL);
529 if (!cd) 529 if (!cd)
530 goto fail; 530 goto fail;
531 memset(cd, 0, sizeof(*cd));
532 531
533 kref_init(&cd->kref); 532 kref_init(&cd->kref);
534 533
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index 5d02ff4db6cc..03fbc4b44473 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -44,11 +44,10 @@ static int sr_read_tochdr(struct cdrom_device_info *cdi,
44 int result; 44 int result;
45 unsigned char *buffer; 45 unsigned char *buffer;
46 46
47 buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd)); 47 buffer = kzalloc(32, GFP_KERNEL | SR_GFP_DMA(cd));
48 if (!buffer) 48 if (!buffer)
49 return -ENOMEM; 49 return -ENOMEM;
50 50
51 memset(&cgc, 0, sizeof(struct packet_command));
52 cgc.timeout = IOCTL_TIMEOUT; 51 cgc.timeout = IOCTL_TIMEOUT;
53 cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP; 52 cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
54 cgc.cmd[8] = 12; /* LSB of length */ 53 cgc.cmd[8] = 12; /* LSB of length */
@@ -74,11 +73,10 @@ static int sr_read_tocentry(struct cdrom_device_info *cdi,
74 int result; 73 int result;
75 unsigned char *buffer; 74 unsigned char *buffer;
76 75
77 buffer = kmalloc(32, GFP_KERNEL | SR_GFP_DMA(cd)); 76 buffer = kzalloc(32, GFP_KERNEL | SR_GFP_DMA(cd));
78 if (!buffer) 77 if (!buffer)
79 return -ENOMEM; 78 return -ENOMEM;
80 79
81 memset(&cgc, 0, sizeof(struct packet_command));
82 cgc.timeout = IOCTL_TIMEOUT; 80 cgc.timeout = IOCTL_TIMEOUT;
83 cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP; 81 cgc.cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
84 cgc.cmd[1] |= (tocentry->cdte_format == CDROM_MSF) ? 0x02 : 0; 82 cgc.cmd[1] |= (tocentry->cdte_format == CDROM_MSF) ? 0x02 : 0;
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 7f96f33c1bb1..f0606da19d02 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -3590,12 +3590,11 @@ static struct st_buffer *
3590 3590
3591 i = sizeof(struct st_buffer) + (max_sg - 1) * sizeof(struct scatterlist) + 3591 i = sizeof(struct st_buffer) + (max_sg - 1) * sizeof(struct scatterlist) +
3592 max_sg * sizeof(struct st_buf_fragment); 3592 max_sg * sizeof(struct st_buf_fragment);
3593 tb = kmalloc(i, priority); 3593 tb = kzalloc(i, priority);
3594 if (!tb) { 3594 if (!tb) {
3595 printk(KERN_NOTICE "st: Can't allocate new tape buffer.\n"); 3595 printk(KERN_NOTICE "st: Can't allocate new tape buffer.\n");
3596 return NULL; 3596 return NULL;
3597 } 3597 }
3598 memset(tb, 0, i);
3599 tb->frp_segs = tb->orig_frp_segs = 0; 3598 tb->frp_segs = tb->orig_frp_segs = 0;
3600 tb->use_sg = max_sg; 3599 tb->use_sg = max_sg;
3601 tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg); 3600 tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg);
@@ -3924,14 +3923,13 @@ static int st_probe(struct device *dev)
3924 goto out_put_disk; 3923 goto out_put_disk;
3925 } 3924 }
3926 3925
3927 tmp_da = kmalloc(tmp_dev_max * sizeof(struct scsi_tape *), GFP_ATOMIC); 3926 tmp_da = kzalloc(tmp_dev_max * sizeof(struct scsi_tape *), GFP_ATOMIC);
3928 if (tmp_da == NULL) { 3927 if (tmp_da == NULL) {
3929 write_unlock(&st_dev_arr_lock); 3928 write_unlock(&st_dev_arr_lock);
3930 printk(KERN_ERR "st: Can't extend device array.\n"); 3929 printk(KERN_ERR "st: Can't extend device array.\n");
3931 goto out_put_disk; 3930 goto out_put_disk;
3932 } 3931 }
3933 3932
3934 memset(tmp_da, 0, tmp_dev_max * sizeof(struct scsi_tape *));
3935 if (scsi_tapes != NULL) { 3933 if (scsi_tapes != NULL) {
3936 memcpy(tmp_da, scsi_tapes, 3934 memcpy(tmp_da, scsi_tapes,
3937 st_dev_max * sizeof(struct scsi_tape *)); 3935 st_dev_max * sizeof(struct scsi_tape *));
@@ -3948,13 +3946,12 @@ static int st_probe(struct device *dev)
3948 if (i >= st_dev_max) 3946 if (i >= st_dev_max)
3949 panic("scsi_devices corrupt (st)"); 3947 panic("scsi_devices corrupt (st)");
3950 3948
3951 tpnt = kmalloc(sizeof(struct scsi_tape), GFP_ATOMIC); 3949 tpnt = kzalloc(sizeof(struct scsi_tape), GFP_ATOMIC);
3952 if (tpnt == NULL) { 3950 if (tpnt == NULL) {
3953 write_unlock(&st_dev_arr_lock); 3951 write_unlock(&st_dev_arr_lock);
3954 printk(KERN_ERR "st: Can't allocate device descriptor.\n"); 3952 printk(KERN_ERR "st: Can't allocate device descriptor.\n");
3955 goto out_put_disk; 3953 goto out_put_disk;
3956 } 3954 }
3957 memset(tpnt, 0, sizeof(struct scsi_tape));
3958 kref_init(&tpnt->kref); 3955 kref_init(&tpnt->kref);
3959 tpnt->disk = disk; 3956 tpnt->disk = disk;
3960 sprintf(disk->disk_name, "st%d", i); 3957 sprintf(disk->disk_name, "st%d", i);