Skip to content

Commit ec4081c

Browse files
Andreas HerrmannJames Bottomley
authored andcommitted
[SCSI] zfcp: (cleanup) kmalloc/kzalloc replacement
Replace kmalloc/memset by kzalloc or kcalloc. Signed-off-by: Andreas Herrmann <aherrman@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
1 parent ca3271b commit ec4081c

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

drivers/s390/scsi/zfcp_aux.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,11 @@ zfcp_cfdc_dev_ioctl(struct file *file, unsigned int command,
289289
goto out;
290290
}
291291

292-
sg_list = kmalloc(sizeof(struct zfcp_sg_list), GFP_KERNEL);
292+
sg_list = kzalloc(sizeof(struct zfcp_sg_list), GFP_KERNEL);
293293
if (sg_list == NULL) {
294294
retval = -ENOMEM;
295295
goto out;
296296
}
297-
memset(sg_list, 0, sizeof(*sg_list));
298297

299298
if (command != ZFCP_CFDC_IOC) {
300299
ZFCP_LOG_INFO("IOC request code 0x%x invalid\n", command);
@@ -476,14 +475,13 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size)
476475
sg_list->count = size >> PAGE_SHIFT;
477476
if (size & ~PAGE_MASK)
478477
sg_list->count++;
479-
sg_list->sg = kmalloc(sg_list->count * sizeof(struct scatterlist),
478+
sg_list->sg = kcalloc(sg_list->count, sizeof(struct scatterlist),
480479
GFP_KERNEL);
481480
if (sg_list->sg == NULL) {
482481
sg_list->count = 0;
483482
retval = -ENOMEM;
484483
goto out;
485484
}
486-
memset(sg_list->sg, 0, sg_list->count * sizeof(struct scatterlist));
487485

488486
for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) {
489487
sg->length = min(size, PAGE_SIZE);
@@ -756,10 +754,9 @@ zfcp_unit_enqueue(struct zfcp_port *port, fcp_lun_t fcp_lun)
756754
if (unit)
757755
return NULL;
758756

759-
unit = kmalloc(sizeof (struct zfcp_unit), GFP_KERNEL);
757+
unit = kzalloc(sizeof (struct zfcp_unit), GFP_KERNEL);
760758
if (!unit)
761759
return NULL;
762-
memset(unit, 0, sizeof (struct zfcp_unit));
763760

764761
/* initialise reference count stuff */
765762
atomic_set(&unit->refcount, 0);
@@ -927,13 +924,12 @@ zfcp_adapter_enqueue(struct ccw_device *ccw_device)
927924
*/
928925

929926
/* try to allocate new adapter data structure (zeroed) */
930-
adapter = kmalloc(sizeof (struct zfcp_adapter), GFP_KERNEL);
927+
adapter = kzalloc(sizeof (struct zfcp_adapter), GFP_KERNEL);
931928
if (!adapter) {
932929
ZFCP_LOG_INFO("error: allocation of base adapter "
933930
"structure failed\n");
934931
goto out;
935932
}
936-
memset(adapter, 0, sizeof (struct zfcp_adapter));
937933

938934
ccw_device->handler = NULL;
939935

@@ -1137,10 +1133,9 @@ zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn, u32 status,
11371133
return NULL;
11381134
}
11391135

1140-
port = kmalloc(sizeof (struct zfcp_port), GFP_KERNEL);
1136+
port = kzalloc(sizeof (struct zfcp_port), GFP_KERNEL);
11411137
if (!port)
11421138
return NULL;
1143-
memset(port, 0, sizeof (struct zfcp_port));
11441139

11451140
/* initialise reference count stuff */
11461141
atomic_set(&port->refcount, 0);

drivers/s390/scsi/zfcp_erp.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,20 +275,17 @@ zfcp_erp_adisc(struct zfcp_port *port)
275275
int retval = 0;
276276
struct timer_list *timer;
277277

278-
send_els = kmalloc(sizeof(struct zfcp_send_els), GFP_ATOMIC);
278+
send_els = kzalloc(sizeof(struct zfcp_send_els), GFP_ATOMIC);
279279
if (send_els == NULL)
280280
goto nomem;
281-
memset(send_els, 0, sizeof(*send_els));
282281

283-
send_els->req = kmalloc(sizeof(struct scatterlist), GFP_ATOMIC);
282+
send_els->req = kzalloc(sizeof(struct scatterlist), GFP_ATOMIC);
284283
if (send_els->req == NULL)
285284
goto nomem;
286-
memset(send_els->req, 0, sizeof(*send_els->req));
287285

288-
send_els->resp = kmalloc(sizeof(struct scatterlist), GFP_ATOMIC);
286+
send_els->resp = kzalloc(sizeof(struct scatterlist), GFP_ATOMIC);
289287
if (send_els->resp == NULL)
290288
goto nomem;
291-
memset(send_els->resp, 0, sizeof(*send_els->resp));
292289

293290
address = (void *) get_zeroed_page(GFP_ATOMIC);
294291
if (address == NULL)

drivers/s390/scsi/zfcp_scsi.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,10 +761,9 @@ zfcp_get_fc_host_stats(struct Scsi_Host *shost)
761761
if (!fc_stats)
762762
return NULL;
763763

764-
data = kmalloc(sizeof(*data), GFP_KERNEL);
764+
data = kzalloc(sizeof(*data), GFP_KERNEL);
765765
if (!data)
766766
return NULL;
767-
memset(data, 0, sizeof(*data));
768767

769768
ret = zfcp_fsf_exchange_port_data(NULL, adapter, data);
770769
if (ret) {
@@ -792,10 +791,9 @@ zfcp_reset_fc_host_stats(struct Scsi_Host *shost)
792791
int ret;
793792

794793
adapter = (struct zfcp_adapter *)shost->hostdata[0];
795-
data = kmalloc(sizeof(*data), GFP_KERNEL);
794+
data = kzalloc(sizeof(*data), GFP_KERNEL);
796795
if (!data)
797796
return;
798-
memset(data, 0, sizeof(*data));
799797

800798
ret = zfcp_fsf_exchange_port_data(NULL, adapter, data);
801799
if (ret == 0) {

0 commit comments

Comments
 (0)