212 lines
8.0 KiB
Plaintext
212 lines
8.0 KiB
Plaintext
|
From: jbeulich@novell.com
|
||
|
Subject: use kzalloc() in favor of kmalloc()+memset()
|
||
|
Patch-mainline: n/a
|
||
|
|
||
|
Also use clear_page() in favor of memset(, 0, PAGE_SIZE).
|
||
|
|
||
|
--- head-2010-04-29.orig/drivers/xen/blkback/blkback.c 2010-03-25 14:38:05.000000000 +0100
|
||
|
+++ head-2010-04-29/drivers/xen/blkback/blkback.c 2010-04-28 16:32:16.000000000 +0200
|
||
|
@@ -671,7 +671,7 @@ static int __init blkif_init(void)
|
||
|
|
||
|
mmap_pages = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
|
||
|
|
||
|
- pending_reqs = kmalloc(sizeof(pending_reqs[0]) *
|
||
|
+ pending_reqs = kzalloc(sizeof(pending_reqs[0]) *
|
||
|
blkif_reqs, GFP_KERNEL);
|
||
|
pending_grant_handles = kmalloc(sizeof(pending_grant_handles[0]) *
|
||
|
mmap_pages, GFP_KERNEL);
|
||
|
@@ -688,7 +688,6 @@ static int __init blkif_init(void)
|
||
|
|
||
|
blkif_interface_init();
|
||
|
|
||
|
- memset(pending_reqs, 0, sizeof(pending_reqs));
|
||
|
INIT_LIST_HEAD(&pending_free);
|
||
|
|
||
|
for (i = 0; i < blkif_reqs; i++)
|
||
|
--- head-2010-04-29.orig/drivers/xen/blkback/interface.c 2010-03-24 15:09:22.000000000 +0100
|
||
|
+++ head-2010-04-29/drivers/xen/blkback/interface.c 2010-04-28 16:37:43.000000000 +0200
|
||
|
@@ -41,11 +41,10 @@ blkif_t *blkif_alloc(domid_t domid)
|
||
|
{
|
||
|
blkif_t *blkif;
|
||
|
|
||
|
- blkif = kmem_cache_alloc(blkif_cachep, GFP_KERNEL);
|
||
|
+ blkif = kmem_cache_alloc(blkif_cachep, GFP_KERNEL|__GFP_ZERO);
|
||
|
if (!blkif)
|
||
|
return ERR_PTR(-ENOMEM);
|
||
|
|
||
|
- memset(blkif, 0, sizeof(*blkif));
|
||
|
blkif->domid = domid;
|
||
|
spin_lock_init(&blkif->blk_ring_lock);
|
||
|
atomic_set(&blkif->refcnt, 1);
|
||
|
--- head-2010-04-29.orig/drivers/xen/blktap/interface.c 2010-03-24 15:09:22.000000000 +0100
|
||
|
+++ head-2010-04-29/drivers/xen/blktap/interface.c 2010-04-28 16:38:55.000000000 +0200
|
||
|
@@ -41,11 +41,10 @@ blkif_t *tap_alloc_blkif(domid_t domid)
|
||
|
{
|
||
|
blkif_t *blkif;
|
||
|
|
||
|
- blkif = kmem_cache_alloc(blkif_cachep, GFP_KERNEL);
|
||
|
+ blkif = kmem_cache_alloc(blkif_cachep, GFP_KERNEL|__GFP_ZERO);
|
||
|
if (!blkif)
|
||
|
return ERR_PTR(-ENOMEM);
|
||
|
|
||
|
- memset(blkif, 0, sizeof(*blkif));
|
||
|
blkif->domid = domid;
|
||
|
spin_lock_init(&blkif->blk_ring_lock);
|
||
|
atomic_set(&blkif->refcnt, 1);
|
||
|
--- head-2010-04-29.orig/drivers/xen/core/machine_reboot.c 2010-03-25 14:39:15.000000000 +0100
|
||
|
+++ head-2010-04-29/drivers/xen/core/machine_reboot.c 2010-04-28 17:04:28.000000000 +0200
|
||
|
@@ -102,7 +102,7 @@ static void post_suspend(int suspend_can
|
||
|
BUG();
|
||
|
HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
|
||
|
|
||
|
- memset(empty_zero_page, 0, PAGE_SIZE);
|
||
|
+ clear_page(empty_zero_page);
|
||
|
|
||
|
fpp = PAGE_SIZE/sizeof(unsigned long);
|
||
|
for (i = 0, j = 0, k = -1; i < max_pfn; i += fpp, j++) {
|
||
|
--- head-2010-04-29.orig/drivers/xen/core/smpboot.c 2010-04-15 11:43:29.000000000 +0200
|
||
|
+++ head-2010-04-29/drivers/xen/core/smpboot.c 2010-04-28 16:44:14.000000000 +0200
|
||
|
@@ -218,17 +218,12 @@ static void __cpuinit cpu_initialize_con
|
||
|
ctxt.flags = VGCF_IN_KERNEL;
|
||
|
ctxt.user_regs.ds = __USER_DS;
|
||
|
ctxt.user_regs.es = __USER_DS;
|
||
|
- ctxt.user_regs.fs = 0;
|
||
|
- ctxt.user_regs.gs = 0;
|
||
|
ctxt.user_regs.ss = __KERNEL_DS;
|
||
|
ctxt.user_regs.eip = (unsigned long)cpu_bringup_and_idle;
|
||
|
ctxt.user_regs.eflags = X86_EFLAGS_IF | 0x1000; /* IOPL_RING1 */
|
||
|
|
||
|
- memset(&ctxt.fpu_ctxt, 0, sizeof(ctxt.fpu_ctxt));
|
||
|
-
|
||
|
smp_trap_init(ctxt.trap_ctxt);
|
||
|
|
||
|
- ctxt.ldt_ents = 0;
|
||
|
ctxt.gdt_frames[0] = arbitrary_virt_to_mfn(get_cpu_gdt_table(cpu));
|
||
|
ctxt.gdt_ents = GDT_SIZE / 8;
|
||
|
|
||
|
--- head-2010-04-29.orig/drivers/xen/netback/interface.c 2010-04-30 10:42:29.000000000 +0200
|
||
|
+++ head-2010-04-29/drivers/xen/netback/interface.c 2010-04-30 10:49:15.000000000 +0200
|
||
|
@@ -227,7 +227,6 @@ netif_t *netif_alloc(struct device *pare
|
||
|
SET_NETDEV_DEV(dev, parent);
|
||
|
|
||
|
netif = netdev_priv(dev);
|
||
|
- memset(netif, 0, sizeof(*netif));
|
||
|
netif->domid = domid;
|
||
|
netif->group = UINT_MAX;
|
||
|
netif->handle = handle;
|
||
|
--- head-2010-04-29.orig/drivers/xen/scsiback/emulate.c 2010-03-24 15:10:29.000000000 +0100
|
||
|
+++ head-2010-04-29/drivers/xen/scsiback/emulate.c 2010-04-28 16:51:05.000000000 +0200
|
||
|
@@ -240,13 +240,11 @@ static void __report_luns(pending_req_t
|
||
|
alloc_len = sizeof(struct scsi_lun) * alloc_luns
|
||
|
+ VSCSI_REPORT_LUNS_HEADER;
|
||
|
retry:
|
||
|
- if ((buff = kmalloc(alloc_len, GFP_KERNEL)) == NULL) {
|
||
|
+ if ((buff = kzalloc(alloc_len, GFP_KERNEL)) == NULL) {
|
||
|
printk(KERN_ERR "scsiback:%s kmalloc err\n", __FUNCTION__);
|
||
|
goto fail;
|
||
|
}
|
||
|
|
||
|
- memset(buff, 0, alloc_len);
|
||
|
-
|
||
|
one_lun = (struct scsi_lun *) &buff[8];
|
||
|
spin_lock_irqsave(&info->v2p_lock, flags);
|
||
|
list_for_each_entry(entry, head, l) {
|
||
|
--- head-2010-04-29.orig/drivers/xen/scsiback/interface.c 2010-03-24 15:09:22.000000000 +0100
|
||
|
+++ head-2010-04-29/drivers/xen/scsiback/interface.c 2010-04-28 16:51:29.000000000 +0200
|
||
|
@@ -46,11 +46,10 @@ struct vscsibk_info *vscsibk_info_alloc(
|
||
|
{
|
||
|
struct vscsibk_info *info;
|
||
|
|
||
|
- info = kmem_cache_alloc(scsiback_cachep, GFP_KERNEL);
|
||
|
+ info = kmem_cache_alloc(scsiback_cachep, GFP_KERNEL|__GFP_ZERO);
|
||
|
if (!info)
|
||
|
return ERR_PTR(-ENOMEM);
|
||
|
|
||
|
- memset(info, 0, sizeof(*info));
|
||
|
info->domid = domid;
|
||
|
spin_lock_init(&info->ring_lock);
|
||
|
atomic_set(&info->nr_unreplied_reqs, 0);
|
||
|
--- head-2010-04-29.orig/drivers/xen/scsiback/scsiback.c 2010-03-24 15:25:21.000000000 +0100
|
||
|
+++ head-2010-04-29/drivers/xen/scsiback/scsiback.c 2010-04-28 16:52:02.000000000 +0200
|
||
|
@@ -676,7 +676,7 @@ static int __init scsiback_init(void)
|
||
|
|
||
|
mmap_pages = vscsiif_reqs * VSCSIIF_SG_TABLESIZE;
|
||
|
|
||
|
- pending_reqs = kmalloc(sizeof(pending_reqs[0]) *
|
||
|
+ pending_reqs = kzalloc(sizeof(pending_reqs[0]) *
|
||
|
vscsiif_reqs, GFP_KERNEL);
|
||
|
pending_grant_handles = kmalloc(sizeof(pending_grant_handles[0]) *
|
||
|
mmap_pages, GFP_KERNEL);
|
||
|
@@ -691,7 +691,6 @@ static int __init scsiback_init(void)
|
||
|
if (scsiback_interface_init() < 0)
|
||
|
goto out_of_kmem;
|
||
|
|
||
|
- memset(pending_reqs, 0, sizeof(pending_reqs));
|
||
|
INIT_LIST_HEAD(&pending_free);
|
||
|
|
||
|
for (i = 0; i < vscsiif_reqs; i++)
|
||
|
--- head-2010-04-29.orig/drivers/xen/sfc_netutil/accel_cuckoo_hash.c 2010-04-15 11:11:11.000000000 +0200
|
||
|
+++ head-2010-04-29/drivers/xen/sfc_netutil/accel_cuckoo_hash.c 2010-04-28 16:54:07.000000000 +0200
|
||
|
@@ -77,7 +77,7 @@ int cuckoo_hash_init(cuckoo_hash_table *
|
||
|
BUG_ON(length_bits >= sizeof(unsigned) * 8);
|
||
|
BUG_ON(key_length > sizeof(cuckoo_hash_key));
|
||
|
|
||
|
- table_mem = kmalloc(sizeof(cuckoo_hash_entry) * 2 * length, GFP_KERNEL);
|
||
|
+ table_mem = kzalloc(sizeof(cuckoo_hash_entry) * 2 * length, GFP_KERNEL);
|
||
|
|
||
|
if (table_mem == NULL)
|
||
|
return -ENOMEM;
|
||
|
@@ -93,9 +93,6 @@ int cuckoo_hash_init(cuckoo_hash_table *
|
||
|
|
||
|
set_hash_parameters(hashtab);
|
||
|
|
||
|
- /* Zero the table */
|
||
|
- memset(hashtab->table0, 0, length * 2 * sizeof(cuckoo_hash_entry));
|
||
|
-
|
||
|
return 0;
|
||
|
}
|
||
|
EXPORT_SYMBOL_GPL(cuckoo_hash_init);
|
||
|
--- head-2010-04-29.orig/drivers/xen/tpmback/interface.c 2010-03-24 15:09:22.000000000 +0100
|
||
|
+++ head-2010-04-29/drivers/xen/tpmback/interface.c 2010-04-28 16:55:39.000000000 +0200
|
||
|
@@ -26,11 +26,10 @@ static tpmif_t *alloc_tpmif(domid_t domi
|
||
|
{
|
||
|
tpmif_t *tpmif;
|
||
|
|
||
|
- tpmif = kmem_cache_alloc(tpmif_cachep, GFP_KERNEL);
|
||
|
+ tpmif = kmem_cache_alloc(tpmif_cachep, GFP_KERNEL|__GFP_ZERO);
|
||
|
if (tpmif == NULL)
|
||
|
goto out_of_memory;
|
||
|
|
||
|
- memset(tpmif, 0, sizeof (*tpmif));
|
||
|
tpmif->domid = domid;
|
||
|
tpmif->status = DISCONNECTED;
|
||
|
tpmif->bi = bi;
|
||
|
@@ -131,7 +130,7 @@ int tpmif_map(tpmif_t *tpmif, unsigned l
|
||
|
}
|
||
|
|
||
|
tpmif->tx = (tpmif_tx_interface_t *)tpmif->tx_area->addr;
|
||
|
- memset(tpmif->tx, 0, PAGE_SIZE);
|
||
|
+ clear_page(tpmif->tx);
|
||
|
|
||
|
err = bind_interdomain_evtchn_to_irqhandler(
|
||
|
tpmif->domid, evtchn, tpmif_be_int, 0, tpmif->devname, tpmif);
|
||
|
--- head-2010-04-29.orig/drivers/xen/usbback/usbback.c 2010-04-15 17:36:18.000000000 +0200
|
||
|
+++ head-2010-04-29/drivers/xen/usbback/usbback.c 2010-04-28 16:56:36.000000000 +0200
|
||
|
@@ -1149,7 +1149,7 @@ static int __init usbback_init(void)
|
||
|
return -ENODEV;
|
||
|
|
||
|
mmap_pages = usbif_reqs * USBIF_MAX_SEGMENTS_PER_REQUEST;
|
||
|
- pending_reqs = kmalloc(sizeof(pending_reqs[0]) *
|
||
|
+ pending_reqs = kzalloc(sizeof(pending_reqs[0]) *
|
||
|
usbif_reqs, GFP_KERNEL);
|
||
|
pending_grant_handles = kmalloc(sizeof(pending_grant_handles[0]) *
|
||
|
mmap_pages, GFP_KERNEL);
|
||
|
@@ -1163,7 +1163,6 @@ static int __init usbback_init(void)
|
||
|
for (i = 0; i < mmap_pages; i++)
|
||
|
pending_grant_handles[i] = USBBACK_INVALID_HANDLE;
|
||
|
|
||
|
- memset(pending_reqs, 0, sizeof(pending_reqs));
|
||
|
INIT_LIST_HEAD(&pending_free);
|
||
|
|
||
|
for (i = 0; i < usbif_reqs; i++)
|