diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2005-11-07 06:31:45 -0500 |
---|---|---|
committer | Jody McIntyre <scjody@modernduck.com> | 2005-11-07 06:31:45 -0500 |
commit | 8551158abc8ef45a7f473a87e69624d05ebfd684 (patch) | |
tree | 47cd79c5f5444c7cac812d797764f203207345a7 /drivers | |
parent | 7afa1467761f06bd9649efd66a4a6b3ff9f29a1f (diff) |
kmalloc/kzalloc changes:
dv1394, eth1394, ieee1394, ohci1394, pcilynx, raw1394, sbp2c, video1394:
- use kzalloc
- provide safer size arguments to kmalloc and kzalloc
- omit some casts
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ieee1394/csr1212.c | 11 | ||||
-rw-r--r-- | drivers/ieee1394/csr1212.h | 2 | ||||
-rw-r--r-- | drivers/ieee1394/dv1394.c | 4 | ||||
-rw-r--r-- | drivers/ieee1394/eth1394.c | 12 | ||||
-rw-r--r-- | drivers/ieee1394/highlevel.c | 18 | ||||
-rw-r--r-- | drivers/ieee1394/hosts.c | 6 | ||||
-rw-r--r-- | drivers/ieee1394/nodemgr.c | 27 | ||||
-rw-r--r-- | drivers/ieee1394/ohci1394.c | 20 | ||||
-rw-r--r-- | drivers/ieee1394/pcilynx.c | 2 | ||||
-rw-r--r-- | drivers/ieee1394/raw1394.c | 38 | ||||
-rw-r--r-- | drivers/ieee1394/sbp2.c | 7 | ||||
-rw-r--r-- | drivers/ieee1394/video1394.c | 81 |
12 files changed, 85 insertions, 143 deletions
diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c index 61ddd5d37eff..c0f8ed6fca8a 100644 --- a/drivers/ieee1394/csr1212.c +++ b/drivers/ieee1394/csr1212.c | |||
@@ -1261,7 +1261,7 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr) | |||
1261 | return CSR1212_EINVAL; | 1261 | return CSR1212_EINVAL; |
1262 | #endif | 1262 | #endif |
1263 | 1263 | ||
1264 | cr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); | 1264 | cr = CSR1212_MALLOC(sizeof(*cr)); |
1265 | if (!cr) | 1265 | if (!cr) |
1266 | return CSR1212_ENOMEM; | 1266 | return CSR1212_ENOMEM; |
1267 | 1267 | ||
@@ -1393,8 +1393,7 @@ int csr1212_parse_keyval(struct csr1212_keyval *kv, | |||
1393 | case CSR1212_KV_TYPE_LEAF: | 1393 | case CSR1212_KV_TYPE_LEAF: |
1394 | if (kv->key.id != CSR1212_KV_ID_EXTENDED_ROM) { | 1394 | if (kv->key.id != CSR1212_KV_ID_EXTENDED_ROM) { |
1395 | kv->value.leaf.data = CSR1212_MALLOC(quads_to_bytes(kvi_len)); | 1395 | kv->value.leaf.data = CSR1212_MALLOC(quads_to_bytes(kvi_len)); |
1396 | if (!kv->value.leaf.data) | 1396 | if (!kv->value.leaf.data) { |
1397 | { | ||
1398 | ret = CSR1212_ENOMEM; | 1397 | ret = CSR1212_ENOMEM; |
1399 | goto fail; | 1398 | goto fail; |
1400 | } | 1399 | } |
@@ -1462,7 +1461,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) | |||
1462 | cache->next = NULL; | 1461 | cache->next = NULL; |
1463 | csr->cache_tail = cache; | 1462 | csr->cache_tail = cache; |
1464 | cache->filled_head = | 1463 | cache->filled_head = |
1465 | CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); | 1464 | CSR1212_MALLOC(sizeof(*cache->filled_head)); |
1466 | if (!cache->filled_head) { | 1465 | if (!cache->filled_head) { |
1467 | return CSR1212_ENOMEM; | 1466 | return CSR1212_ENOMEM; |
1468 | } | 1467 | } |
@@ -1484,7 +1483,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) | |||
1484 | /* Now seach read portions of the cache to see if it is there. */ | 1483 | /* Now seach read portions of the cache to see if it is there. */ |
1485 | for (cr = cache->filled_head; cr; cr = cr->next) { | 1484 | for (cr = cache->filled_head; cr; cr = cr->next) { |
1486 | if (cache_index < cr->offset_start) { | 1485 | if (cache_index < cr->offset_start) { |
1487 | newcr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); | 1486 | newcr = CSR1212_MALLOC(sizeof(*newcr)); |
1488 | if (!newcr) | 1487 | if (!newcr) |
1489 | return CSR1212_ENOMEM; | 1488 | return CSR1212_ENOMEM; |
1490 | 1489 | ||
@@ -1508,7 +1507,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) | |||
1508 | 1507 | ||
1509 | if (!cr) { | 1508 | if (!cr) { |
1510 | cr = cache->filled_tail; | 1509 | cr = cache->filled_tail; |
1511 | newcr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); | 1510 | newcr = CSR1212_MALLOC(sizeof(*newcr)); |
1512 | if (!newcr) | 1511 | if (!newcr) |
1513 | return CSR1212_ENOMEM; | 1512 | return CSR1212_ENOMEM; |
1514 | 1513 | ||
diff --git a/drivers/ieee1394/csr1212.h b/drivers/ieee1394/csr1212.h index 28c5f4b726e2..cecd5871f2de 100644 --- a/drivers/ieee1394/csr1212.h +++ b/drivers/ieee1394/csr1212.h | |||
@@ -646,7 +646,7 @@ static inline struct csr1212_csr_rom_cache *csr1212_rom_cache_malloc(u_int32_t o | |||
646 | { | 646 | { |
647 | struct csr1212_csr_rom_cache *cache; | 647 | struct csr1212_csr_rom_cache *cache; |
648 | 648 | ||
649 | cache = CSR1212_MALLOC(sizeof(struct csr1212_csr_rom_cache) + size); | 649 | cache = CSR1212_MALLOC(sizeof(*cache) + size); |
650 | if (!cache) | 650 | if (!cache) |
651 | return NULL; | 651 | return NULL; |
652 | 652 | ||
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c index cbbbe14b8849..d204ec772c0a 100644 --- a/drivers/ieee1394/dv1394.c +++ b/drivers/ieee1394/dv1394.c | |||
@@ -2218,14 +2218,12 @@ static int dv1394_init(struct ti_ohci *ohci, enum pal_or_ntsc format, enum modes | |||
2218 | unsigned long flags; | 2218 | unsigned long flags; |
2219 | int i; | 2219 | int i; |
2220 | 2220 | ||
2221 | video = kmalloc(sizeof(struct video_card), GFP_KERNEL); | 2221 | video = kzalloc(sizeof(*video), GFP_KERNEL); |
2222 | if (!video) { | 2222 | if (!video) { |
2223 | printk(KERN_ERR "dv1394: cannot allocate video_card\n"); | 2223 | printk(KERN_ERR "dv1394: cannot allocate video_card\n"); |
2224 | goto err; | 2224 | goto err; |
2225 | } | 2225 | } |
2226 | 2226 | ||
2227 | memset(video, 0, sizeof(struct video_card)); | ||
2228 | |||
2229 | video->ohci = ohci; | 2227 | video->ohci = ohci; |
2230 | /* lower 2 bits of id indicate which of four "plugs" | 2228 | /* lower 2 bits of id indicate which of four "plugs" |
2231 | per host */ | 2229 | per host */ |
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c index 6984a921b59b..30fa0d43a43a 100644 --- a/drivers/ieee1394/eth1394.c +++ b/drivers/ieee1394/eth1394.c | |||
@@ -352,12 +352,12 @@ static int eth1394_probe(struct device *dev) | |||
352 | if (!hi) | 352 | if (!hi) |
353 | return -ENOENT; | 353 | return -ENOENT; |
354 | 354 | ||
355 | new_node = kmalloc(sizeof(struct eth1394_node_ref), | 355 | new_node = kmalloc(sizeof(*new_node), |
356 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); | 356 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); |
357 | if (!new_node) | 357 | if (!new_node) |
358 | return -ENOMEM; | 358 | return -ENOMEM; |
359 | 359 | ||
360 | node_info = kmalloc(sizeof(struct eth1394_node_info), | 360 | node_info = kmalloc(sizeof(*node_info), |
361 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); | 361 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); |
362 | if (!node_info) { | 362 | if (!node_info) { |
363 | kfree(new_node); | 363 | kfree(new_node); |
@@ -433,12 +433,12 @@ static int eth1394_update(struct unit_directory *ud) | |||
433 | node = eth1394_find_node(&priv->ip_node_list, ud); | 433 | node = eth1394_find_node(&priv->ip_node_list, ud); |
434 | 434 | ||
435 | if (!node) { | 435 | if (!node) { |
436 | node = kmalloc(sizeof(struct eth1394_node_ref), | 436 | node = kmalloc(sizeof(*node), |
437 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); | 437 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); |
438 | if (!node) | 438 | if (!node) |
439 | return -ENOMEM; | 439 | return -ENOMEM; |
440 | 440 | ||
441 | node_info = kmalloc(sizeof(struct eth1394_node_info), | 441 | node_info = kmalloc(sizeof(*node_info), |
442 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); | 442 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); |
443 | if (!node_info) { | 443 | if (!node_info) { |
444 | kfree(node); | 444 | kfree(node); |
@@ -1014,7 +1014,7 @@ static inline int new_fragment(struct list_head *frag_info, int offset, int len) | |||
1014 | } | 1014 | } |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | new = kmalloc(sizeof(struct fragment_info), GFP_ATOMIC); | 1017 | new = kmalloc(sizeof(*new), GFP_ATOMIC); |
1018 | if (!new) | 1018 | if (!new) |
1019 | return -ENOMEM; | 1019 | return -ENOMEM; |
1020 | 1020 | ||
@@ -1033,7 +1033,7 @@ static inline int new_partial_datagram(struct net_device *dev, | |||
1033 | { | 1033 | { |
1034 | struct partial_datagram *new; | 1034 | struct partial_datagram *new; |
1035 | 1035 | ||
1036 | new = kmalloc(sizeof(struct partial_datagram), GFP_ATOMIC); | 1036 | new = kmalloc(sizeof(*new), GFP_ATOMIC); |
1037 | if (!new) | 1037 | if (!new) |
1038 | return -ENOMEM; | 1038 | return -ENOMEM; |
1039 | 1039 | ||
diff --git a/drivers/ieee1394/highlevel.c b/drivers/ieee1394/highlevel.c index 997e1bf6297f..734b121a0554 100644 --- a/drivers/ieee1394/highlevel.c +++ b/drivers/ieee1394/highlevel.c | |||
@@ -101,12 +101,10 @@ void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host, | |||
101 | return NULL; | 101 | return NULL; |
102 | } | 102 | } |
103 | 103 | ||
104 | hi = kmalloc(sizeof(*hi) + data_size, GFP_ATOMIC); | 104 | hi = kzalloc(sizeof(*hi) + data_size, GFP_ATOMIC); |
105 | if (!hi) | 105 | if (!hi) |
106 | return NULL; | 106 | return NULL; |
107 | 107 | ||
108 | memset(hi, 0, sizeof(*hi) + data_size); | ||
109 | |||
110 | if (data_size) { | 108 | if (data_size) { |
111 | data = hi->data = hi + 1; | 109 | data = hi->data = hi + 1; |
112 | hi->size = data_size; | 110 | hi->size = data_size; |
@@ -326,11 +324,9 @@ u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl, | |||
326 | return retval; | 324 | return retval; |
327 | } | 325 | } |
328 | 326 | ||
329 | as = (struct hpsb_address_serve *) | 327 | as = kmalloc(sizeof(*as), GFP_KERNEL); |
330 | kmalloc(sizeof(struct hpsb_address_serve), GFP_KERNEL); | 328 | if (!as) |
331 | if (as == NULL) { | ||
332 | return retval; | 329 | return retval; |
333 | } | ||
334 | 330 | ||
335 | INIT_LIST_HEAD(&as->host_list); | 331 | INIT_LIST_HEAD(&as->host_list); |
336 | INIT_LIST_HEAD(&as->hl_list); | 332 | INIT_LIST_HEAD(&as->hl_list); |
@@ -383,11 +379,9 @@ int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host, | |||
383 | return 0; | 379 | return 0; |
384 | } | 380 | } |
385 | 381 | ||
386 | as = (struct hpsb_address_serve *) | 382 | as = kmalloc(sizeof(*as), GFP_ATOMIC); |
387 | kmalloc(sizeof(struct hpsb_address_serve), GFP_ATOMIC); | 383 | if (!as) |
388 | if (as == NULL) { | 384 | return 0; |
389 | return 0; | ||
390 | } | ||
391 | 385 | ||
392 | INIT_LIST_HEAD(&as->host_list); | 386 | INIT_LIST_HEAD(&as->host_list); |
393 | INIT_LIST_HEAD(&as->hl_list); | 387 | INIT_LIST_HEAD(&as->hl_list); |
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c index aeeaeb670d03..d245abe4033c 100644 --- a/drivers/ieee1394/hosts.c +++ b/drivers/ieee1394/hosts.c | |||
@@ -114,9 +114,9 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, | |||
114 | int i; | 114 | int i; |
115 | int hostnum = 0; | 115 | int hostnum = 0; |
116 | 116 | ||
117 | h = kmalloc(sizeof(struct hpsb_host) + extra, SLAB_KERNEL); | 117 | h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL); |
118 | if (!h) return NULL; | 118 | if (!h) |
119 | memset(h, 0, sizeof(struct hpsb_host) + extra); | 119 | return NULL; |
120 | 120 | ||
121 | h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h); | 121 | h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h); |
122 | if (!h->csr.rom) { | 122 | if (!h->csr.rom) { |
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 7fff5a1d2ea4..3f0917bbd7f5 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c | |||
@@ -743,21 +743,20 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr | |||
743 | unsigned int generation) | 743 | unsigned int generation) |
744 | { | 744 | { |
745 | struct hpsb_host *host = hi->host; | 745 | struct hpsb_host *host = hi->host; |
746 | struct node_entry *ne; | 746 | struct node_entry *ne; |
747 | |||
748 | ne = kmalloc(sizeof(struct node_entry), GFP_KERNEL); | ||
749 | if (!ne) return NULL; | ||
750 | 747 | ||
751 | memset(ne, 0, sizeof(struct node_entry)); | 748 | ne = kzalloc(sizeof(*ne), GFP_KERNEL); |
749 | if (!ne) | ||
750 | return NULL; | ||
752 | 751 | ||
753 | ne->tpool = &host->tpool[nodeid & NODE_MASK]; | 752 | ne->tpool = &host->tpool[nodeid & NODE_MASK]; |
754 | 753 | ||
755 | ne->host = host; | 754 | ne->host = host; |
756 | ne->nodeid = nodeid; | 755 | ne->nodeid = nodeid; |
757 | ne->generation = generation; | 756 | ne->generation = generation; |
758 | ne->needs_probe = 1; | 757 | ne->needs_probe = 1; |
759 | 758 | ||
760 | ne->guid = guid; | 759 | ne->guid = guid; |
761 | ne->guid_vendor_id = (guid >> 40) & 0xffffff; | 760 | ne->guid_vendor_id = (guid >> 40) & 0xffffff; |
762 | ne->guid_vendor_oui = nodemgr_find_oui_name(ne->guid_vendor_id); | 761 | ne->guid_vendor_oui = nodemgr_find_oui_name(ne->guid_vendor_id); |
763 | ne->csr = csr; | 762 | ne->csr = csr; |
@@ -787,7 +786,7 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr | |||
787 | (host->node_id == nodeid) ? "Host" : "Node", | 786 | (host->node_id == nodeid) ? "Host" : "Node", |
788 | NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid); | 787 | NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid); |
789 | 788 | ||
790 | return ne; | 789 | return ne; |
791 | } | 790 | } |
792 | 791 | ||
793 | 792 | ||
@@ -872,12 +871,10 @@ static struct unit_directory *nodemgr_process_unit_directory | |||
872 | struct csr1212_keyval *kv; | 871 | struct csr1212_keyval *kv; |
873 | u8 last_key_id = 0; | 872 | u8 last_key_id = 0; |
874 | 873 | ||
875 | ud = kmalloc(sizeof(struct unit_directory), GFP_KERNEL); | 874 | ud = kzalloc(sizeof(*ud), GFP_KERNEL); |
876 | if (!ud) | 875 | if (!ud) |
877 | goto unit_directory_error; | 876 | goto unit_directory_error; |
878 | 877 | ||
879 | memset (ud, 0, sizeof(struct unit_directory)); | ||
880 | |||
881 | ud->ne = ne; | 878 | ud->ne = ne; |
882 | ud->ignore_driver = ignore_drivers; | 879 | ud->ignore_driver = ignore_drivers; |
883 | ud->address = ud_kv->offset + CSR1212_CONFIG_ROM_SPACE_BASE; | 880 | ud->address = ud_kv->offset + CSR1212_CONFIG_ROM_SPACE_BASE; |
@@ -937,10 +934,10 @@ static struct unit_directory *nodemgr_process_unit_directory | |||
937 | /* Logical Unit Number */ | 934 | /* Logical Unit Number */ |
938 | if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { | 935 | if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { |
939 | if (ud->flags & UNIT_DIRECTORY_HAS_LUN) { | 936 | if (ud->flags & UNIT_DIRECTORY_HAS_LUN) { |
940 | ud_child = kmalloc(sizeof(struct unit_directory), GFP_KERNEL); | 937 | ud_child = kmalloc(sizeof(*ud_child), GFP_KERNEL); |
941 | if (!ud_child) | 938 | if (!ud_child) |
942 | goto unit_directory_error; | 939 | goto unit_directory_error; |
943 | memcpy(ud_child, ud, sizeof(struct unit_directory)); | 940 | memcpy(ud_child, ud, sizeof(*ud_child)); |
944 | nodemgr_register_device(ne, ud_child, &ne->device); | 941 | nodemgr_register_device(ne, ud_child, &ne->device); |
945 | ud_child = NULL; | 942 | ud_child = NULL; |
946 | 943 | ||
@@ -1200,7 +1197,7 @@ static void nodemgr_node_scan_one(struct host_info *hi, | |||
1200 | struct csr1212_csr *csr; | 1197 | struct csr1212_csr *csr; |
1201 | struct nodemgr_csr_info *ci; | 1198 | struct nodemgr_csr_info *ci; |
1202 | 1199 | ||
1203 | ci = kmalloc(sizeof(struct nodemgr_csr_info), GFP_KERNEL); | 1200 | ci = kmalloc(sizeof(*ci), GFP_KERNEL); |
1204 | if (!ci) | 1201 | if (!ci) |
1205 | return; | 1202 | return; |
1206 | 1203 | ||
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index 8355068b0696..97b6f48033c4 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c | |||
@@ -2957,28 +2957,23 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d, | |||
2957 | d->ctrlClear = 0; | 2957 | d->ctrlClear = 0; |
2958 | d->cmdPtr = 0; | 2958 | d->cmdPtr = 0; |
2959 | 2959 | ||
2960 | d->buf_cpu = kmalloc(d->num_desc * sizeof(quadlet_t*), GFP_ATOMIC); | 2960 | d->buf_cpu = kzalloc(d->num_desc * sizeof(*d->buf_cpu), GFP_ATOMIC); |
2961 | d->buf_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_ATOMIC); | 2961 | d->buf_bus = kzalloc(d->num_desc * sizeof(*d->buf_bus), GFP_ATOMIC); |
2962 | 2962 | ||
2963 | if (d->buf_cpu == NULL || d->buf_bus == NULL) { | 2963 | if (d->buf_cpu == NULL || d->buf_bus == NULL) { |
2964 | PRINT(KERN_ERR, "Failed to allocate dma buffer"); | 2964 | PRINT(KERN_ERR, "Failed to allocate dma buffer"); |
2965 | free_dma_rcv_ctx(d); | 2965 | free_dma_rcv_ctx(d); |
2966 | return -ENOMEM; | 2966 | return -ENOMEM; |
2967 | } | 2967 | } |
2968 | memset(d->buf_cpu, 0, d->num_desc * sizeof(quadlet_t*)); | ||
2969 | memset(d->buf_bus, 0, d->num_desc * sizeof(dma_addr_t)); | ||
2970 | 2968 | ||
2971 | d->prg_cpu = kmalloc(d->num_desc * sizeof(struct dma_cmd*), | 2969 | d->prg_cpu = kzalloc(d->num_desc * sizeof(*d->prg_cpu), GFP_ATOMIC); |
2972 | GFP_ATOMIC); | 2970 | d->prg_bus = kzalloc(d->num_desc * sizeof(*d->prg_bus), GFP_ATOMIC); |
2973 | d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_ATOMIC); | ||
2974 | 2971 | ||
2975 | if (d->prg_cpu == NULL || d->prg_bus == NULL) { | 2972 | if (d->prg_cpu == NULL || d->prg_bus == NULL) { |
2976 | PRINT(KERN_ERR, "Failed to allocate dma prg"); | 2973 | PRINT(KERN_ERR, "Failed to allocate dma prg"); |
2977 | free_dma_rcv_ctx(d); | 2974 | free_dma_rcv_ctx(d); |
2978 | return -ENOMEM; | 2975 | return -ENOMEM; |
2979 | } | 2976 | } |
2980 | memset(d->prg_cpu, 0, d->num_desc * sizeof(struct dma_cmd*)); | ||
2981 | memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t)); | ||
2982 | 2977 | ||
2983 | d->spb = kmalloc(d->split_buf_size, GFP_ATOMIC); | 2978 | d->spb = kmalloc(d->split_buf_size, GFP_ATOMIC); |
2984 | 2979 | ||
@@ -3090,17 +3085,14 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d, | |||
3090 | d->ctrlClear = 0; | 3085 | d->ctrlClear = 0; |
3091 | d->cmdPtr = 0; | 3086 | d->cmdPtr = 0; |
3092 | 3087 | ||
3093 | d->prg_cpu = kmalloc(d->num_desc * sizeof(struct at_dma_prg*), | 3088 | d->prg_cpu = kzalloc(d->num_desc * sizeof(*d->prg_cpu), GFP_KERNEL); |
3094 | GFP_KERNEL); | 3089 | d->prg_bus = kzalloc(d->num_desc * sizeof(*d->prg_bus), GFP_KERNEL); |
3095 | d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_KERNEL); | ||
3096 | 3090 | ||
3097 | if (d->prg_cpu == NULL || d->prg_bus == NULL) { | 3091 | if (d->prg_cpu == NULL || d->prg_bus == NULL) { |
3098 | PRINT(KERN_ERR, "Failed to allocate at dma prg"); | 3092 | PRINT(KERN_ERR, "Failed to allocate at dma prg"); |
3099 | free_dma_trm_ctx(d); | 3093 | free_dma_trm_ctx(d); |
3100 | return -ENOMEM; | 3094 | return -ENOMEM; |
3101 | } | 3095 | } |
3102 | memset(d->prg_cpu, 0, d->num_desc * sizeof(struct at_dma_prg*)); | ||
3103 | memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t)); | ||
3104 | 3096 | ||
3105 | len = sprintf(pool_name, "ohci1394_trm_prg"); | 3097 | len = sprintf(pool_name, "ohci1394_trm_prg"); |
3106 | sprintf(pool_name+len, "%d", num_allocs); | 3098 | sprintf(pool_name+len, "%d", num_allocs); |
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c index 6b1ab875333b..e2edc41e1b6f 100644 --- a/drivers/ieee1394/pcilynx.c +++ b/drivers/ieee1394/pcilynx.c | |||
@@ -1435,7 +1435,7 @@ static int __devinit add_card(struct pci_dev *dev, | |||
1435 | struct i2c_algo_bit_data i2c_adapter_data; | 1435 | struct i2c_algo_bit_data i2c_adapter_data; |
1436 | 1436 | ||
1437 | error = -ENOMEM; | 1437 | error = -ENOMEM; |
1438 | i2c_ad = kmalloc(sizeof(struct i2c_adapter), SLAB_KERNEL); | 1438 | i2c_ad = kmalloc(sizeof(*i2c_ad), SLAB_KERNEL); |
1439 | if (!i2c_ad) FAIL("failed to allocate I2C adapter memory"); | 1439 | if (!i2c_ad) FAIL("failed to allocate I2C adapter memory"); |
1440 | 1440 | ||
1441 | memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter)); | 1441 | memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter)); |
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index 24411e666b21..0278dc5d5ef9 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c | |||
@@ -102,12 +102,9 @@ static struct pending_request *__alloc_pending_request(gfp_t flags) | |||
102 | { | 102 | { |
103 | struct pending_request *req; | 103 | struct pending_request *req; |
104 | 104 | ||
105 | req = (struct pending_request *)kmalloc(sizeof(struct pending_request), | 105 | req = kzalloc(sizeof(*req), flags); |
106 | flags); | 106 | if (req) |
107 | if (req != NULL) { | ||
108 | memset(req, 0, sizeof(struct pending_request)); | ||
109 | INIT_LIST_HEAD(&req->list); | 107 | INIT_LIST_HEAD(&req->list); |
110 | } | ||
111 | 108 | ||
112 | return req; | 109 | return req; |
113 | } | 110 | } |
@@ -192,9 +189,9 @@ static void add_host(struct hpsb_host *host) | |||
192 | struct host_info *hi; | 189 | struct host_info *hi; |
193 | unsigned long flags; | 190 | unsigned long flags; |
194 | 191 | ||
195 | hi = (struct host_info *)kmalloc(sizeof(struct host_info), GFP_KERNEL); | 192 | hi = kmalloc(sizeof(*hi), GFP_KERNEL); |
196 | 193 | ||
197 | if (hi != NULL) { | 194 | if (hi) { |
198 | INIT_LIST_HEAD(&hi->list); | 195 | INIT_LIST_HEAD(&hi->list); |
199 | hi->host = host; | 196 | hi->host = host; |
200 | INIT_LIST_HEAD(&hi->file_info_list); | 197 | INIT_LIST_HEAD(&hi->file_info_list); |
@@ -315,8 +312,8 @@ static void iso_receive(struct hpsb_host *host, int channel, quadlet_t * data, | |||
315 | break; | 312 | break; |
316 | 313 | ||
317 | if (!ibs) { | 314 | if (!ibs) { |
318 | ibs = kmalloc(sizeof(struct iso_block_store) | 315 | ibs = kmalloc(sizeof(*ibs) + length, |
319 | + length, SLAB_ATOMIC); | 316 | SLAB_ATOMIC); |
320 | if (!ibs) { | 317 | if (!ibs) { |
321 | kfree(req); | 318 | kfree(req); |
322 | break; | 319 | break; |
@@ -376,8 +373,8 @@ static void fcp_request(struct hpsb_host *host, int nodeid, int direction, | |||
376 | break; | 373 | break; |
377 | 374 | ||
378 | if (!ibs) { | 375 | if (!ibs) { |
379 | ibs = kmalloc(sizeof(struct iso_block_store) | 376 | ibs = kmalloc(sizeof(*ibs) + length, |
380 | + length, SLAB_ATOMIC); | 377 | SLAB_ATOMIC); |
381 | if (!ibs) { | 378 | if (!ibs) { |
382 | kfree(req); | 379 | kfree(req); |
383 | break; | 380 | break; |
@@ -502,10 +499,9 @@ static int state_initialized(struct file_info *fi, struct pending_request *req) | |||
502 | switch (req->req.type) { | 499 | switch (req->req.type) { |
503 | case RAW1394_REQ_LIST_CARDS: | 500 | case RAW1394_REQ_LIST_CARDS: |
504 | spin_lock_irqsave(&host_info_lock, flags); | 501 | spin_lock_irqsave(&host_info_lock, flags); |
505 | khl = kmalloc(sizeof(struct raw1394_khost_list) * host_count, | 502 | khl = kmalloc(sizeof(*khl) * host_count, SLAB_ATOMIC); |
506 | SLAB_ATOMIC); | ||
507 | 503 | ||
508 | if (khl != NULL) { | 504 | if (khl) { |
509 | req->req.misc = host_count; | 505 | req->req.misc = host_count; |
510 | req->data = (quadlet_t *) khl; | 506 | req->data = (quadlet_t *) khl; |
511 | 507 | ||
@@ -517,7 +513,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req) | |||
517 | } | 513 | } |
518 | spin_unlock_irqrestore(&host_info_lock, flags); | 514 | spin_unlock_irqrestore(&host_info_lock, flags); |
519 | 515 | ||
520 | if (khl != NULL) { | 516 | if (khl) { |
521 | req->req.error = RAW1394_ERROR_NONE; | 517 | req->req.error = RAW1394_ERROR_NONE; |
522 | req->req.length = min(req->req.length, | 518 | req->req.length = min(req->req.length, |
523 | (u32) (sizeof | 519 | (u32) (sizeof |
@@ -1647,13 +1643,13 @@ static int arm_register(struct file_info *fi, struct pending_request *req) | |||
1647 | return (-EINVAL); | 1643 | return (-EINVAL); |
1648 | } | 1644 | } |
1649 | /* addr-list-entry for fileinfo */ | 1645 | /* addr-list-entry for fileinfo */ |
1650 | addr = (struct arm_addr *)kmalloc(sizeof(struct arm_addr), SLAB_KERNEL); | 1646 | addr = kmalloc(sizeof(*addr), SLAB_KERNEL); |
1651 | if (!addr) { | 1647 | if (!addr) { |
1652 | req->req.length = 0; | 1648 | req->req.length = 0; |
1653 | return (-ENOMEM); | 1649 | return (-ENOMEM); |
1654 | } | 1650 | } |
1655 | /* allocation of addr_space_buffer */ | 1651 | /* allocation of addr_space_buffer */ |
1656 | addr->addr_space_buffer = (u8 *) vmalloc(req->req.length); | 1652 | addr->addr_space_buffer = vmalloc(req->req.length); |
1657 | if (!(addr->addr_space_buffer)) { | 1653 | if (!(addr->addr_space_buffer)) { |
1658 | kfree(addr); | 1654 | kfree(addr); |
1659 | req->req.length = 0; | 1655 | req->req.length = 0; |
@@ -2122,8 +2118,7 @@ static int modify_config_rom(struct file_info *fi, struct pending_request *req) | |||
2122 | return -ENOMEM; | 2118 | return -ENOMEM; |
2123 | } | 2119 | } |
2124 | 2120 | ||
2125 | cache->filled_head = | 2121 | cache->filled_head = kmalloc(sizeof(*cache->filled_head), GFP_KERNEL); |
2126 | kmalloc(sizeof(struct csr1212_cache_region), GFP_KERNEL); | ||
2127 | if (!cache->filled_head) { | 2122 | if (!cache->filled_head) { |
2128 | csr1212_release_keyval(fi->csr1212_dirs[dr]); | 2123 | csr1212_release_keyval(fi->csr1212_dirs[dr]); |
2129 | fi->csr1212_dirs[dr] = NULL; | 2124 | fi->csr1212_dirs[dr] = NULL; |
@@ -2684,11 +2679,10 @@ static int raw1394_open(struct inode *inode, struct file *file) | |||
2684 | { | 2679 | { |
2685 | struct file_info *fi; | 2680 | struct file_info *fi; |
2686 | 2681 | ||
2687 | fi = kmalloc(sizeof(struct file_info), SLAB_KERNEL); | 2682 | fi = kzalloc(sizeof(*fi), SLAB_KERNEL); |
2688 | if (fi == NULL) | 2683 | if (!fi) |
2689 | return -ENOMEM; | 2684 | return -ENOMEM; |
2690 | 2685 | ||
2691 | memset(fi, 0, sizeof(struct file_info)); | ||
2692 | fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */ | 2686 | fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */ |
2693 | 2687 | ||
2694 | INIT_LIST_HEAD(&fi->list); | 2688 | INIT_LIST_HEAD(&fi->list); |
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index b871116fa4d1..84875cd5a70d 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c | |||
@@ -411,14 +411,12 @@ static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_i | |||
411 | 411 | ||
412 | spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); | 412 | spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); |
413 | for (i = 0; i < orbs; i++) { | 413 | for (i = 0; i < orbs; i++) { |
414 | command = (struct sbp2_command_info *) | 414 | command = kzalloc(sizeof(*command), GFP_ATOMIC); |
415 | kmalloc(sizeof(struct sbp2_command_info), GFP_ATOMIC); | ||
416 | if (!command) { | 415 | if (!command) { |
417 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, | 416 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, |
418 | flags); | 417 | flags); |
419 | return -ENOMEM; | 418 | return -ENOMEM; |
420 | } | 419 | } |
421 | memset(command, '\0', sizeof(struct sbp2_command_info)); | ||
422 | command->command_orb_dma = | 420 | command->command_orb_dma = |
423 | pci_map_single(hi->host->pdev, &command->command_orb, | 421 | pci_map_single(hi->host->pdev, &command->command_orb, |
424 | sizeof(struct sbp2_command_orb), | 422 | sizeof(struct sbp2_command_orb), |
@@ -714,12 +712,11 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud | |||
714 | 712 | ||
715 | SBP2_DEBUG("sbp2_alloc_device"); | 713 | SBP2_DEBUG("sbp2_alloc_device"); |
716 | 714 | ||
717 | scsi_id = kmalloc(sizeof(*scsi_id), GFP_KERNEL); | 715 | scsi_id = kzalloc(sizeof(*scsi_id), GFP_KERNEL); |
718 | if (!scsi_id) { | 716 | if (!scsi_id) { |
719 | SBP2_ERR("failed to create scsi_id"); | 717 | SBP2_ERR("failed to create scsi_id"); |
720 | goto failed_alloc; | 718 | goto failed_alloc; |
721 | } | 719 | } |
722 | memset(scsi_id, 0, sizeof(*scsi_id)); | ||
723 | 720 | ||
724 | scsi_id->ne = ud->ne; | 721 | scsi_id->ne = ud->ne; |
725 | scsi_id->ud = ud; | 722 | scsi_id->ud = ud; |
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index 23911da50154..2ad30cd7c5aa 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c | |||
@@ -206,14 +206,12 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, | |||
206 | struct dma_iso_ctx *d; | 206 | struct dma_iso_ctx *d; |
207 | int i; | 207 | int i; |
208 | 208 | ||
209 | d = kmalloc(sizeof(struct dma_iso_ctx), GFP_KERNEL); | 209 | d = kzalloc(sizeof(*d), GFP_KERNEL); |
210 | if (d == NULL) { | 210 | if (!d) { |
211 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma_iso_ctx"); | 211 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma_iso_ctx"); |
212 | return NULL; | 212 | return NULL; |
213 | } | 213 | } |
214 | 214 | ||
215 | memset(d, 0, sizeof *d); | ||
216 | |||
217 | d->ohci = ohci; | 215 | d->ohci = ohci; |
218 | d->type = type; | 216 | d->type = type; |
219 | d->channel = channel; | 217 | d->channel = channel; |
@@ -251,9 +249,8 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, | |||
251 | } | 249 | } |
252 | d->ctx = d->iso_tasklet.context; | 250 | d->ctx = d->iso_tasklet.context; |
253 | 251 | ||
254 | d->prg_reg = kmalloc(d->num_desc * sizeof(struct dma_prog_region), | 252 | d->prg_reg = kmalloc(d->num_desc * sizeof(*d->prg_reg), GFP_KERNEL); |
255 | GFP_KERNEL); | 253 | if (!d->prg_reg) { |
256 | if (d->prg_reg == NULL) { | ||
257 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate ir prg regs"); | 254 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate ir prg regs"); |
258 | free_dma_iso_ctx(d); | 255 | free_dma_iso_ctx(d); |
259 | return NULL; | 256 | return NULL; |
@@ -268,15 +265,14 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, | |||
268 | d->cmdPtr = OHCI1394_IsoRcvCommandPtr+32*d->ctx; | 265 | d->cmdPtr = OHCI1394_IsoRcvCommandPtr+32*d->ctx; |
269 | d->ctxMatch = OHCI1394_IsoRcvContextMatch+32*d->ctx; | 266 | d->ctxMatch = OHCI1394_IsoRcvContextMatch+32*d->ctx; |
270 | 267 | ||
271 | d->ir_prg = kmalloc(d->num_desc * sizeof(struct dma_cmd *), | 268 | d->ir_prg = kzalloc(d->num_desc * sizeof(*d->ir_prg), |
272 | GFP_KERNEL); | 269 | GFP_KERNEL); |
273 | 270 | ||
274 | if (d->ir_prg == NULL) { | 271 | if (!d->ir_prg) { |
275 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma ir prg"); | 272 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma ir prg"); |
276 | free_dma_iso_ctx(d); | 273 | free_dma_iso_ctx(d); |
277 | return NULL; | 274 | return NULL; |
278 | } | 275 | } |
279 | memset(d->ir_prg, 0, d->num_desc * sizeof(struct dma_cmd *)); | ||
280 | 276 | ||
281 | d->nb_cmd = d->buf_size / PAGE_SIZE + 1; | 277 | d->nb_cmd = d->buf_size / PAGE_SIZE + 1; |
282 | d->left_size = (d->frame_size % PAGE_SIZE) ? | 278 | d->left_size = (d->frame_size % PAGE_SIZE) ? |
@@ -297,16 +293,15 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, | |||
297 | d->ctrlClear = OHCI1394_IsoXmitContextControlClear+16*d->ctx; | 293 | d->ctrlClear = OHCI1394_IsoXmitContextControlClear+16*d->ctx; |
298 | d->cmdPtr = OHCI1394_IsoXmitCommandPtr+16*d->ctx; | 294 | d->cmdPtr = OHCI1394_IsoXmitCommandPtr+16*d->ctx; |
299 | 295 | ||
300 | d->it_prg = kmalloc(d->num_desc * sizeof(struct it_dma_prg *), | 296 | d->it_prg = kzalloc(d->num_desc * sizeof(*d->it_prg), |
301 | GFP_KERNEL); | 297 | GFP_KERNEL); |
302 | 298 | ||
303 | if (d->it_prg == NULL) { | 299 | if (!d->it_prg) { |
304 | PRINT(KERN_ERR, ohci->host->id, | 300 | PRINT(KERN_ERR, ohci->host->id, |
305 | "Failed to allocate dma it prg"); | 301 | "Failed to allocate dma it prg"); |
306 | free_dma_iso_ctx(d); | 302 | free_dma_iso_ctx(d); |
307 | return NULL; | 303 | return NULL; |
308 | } | 304 | } |
309 | memset(d->it_prg, 0, d->num_desc*sizeof(struct it_dma_prg *)); | ||
310 | 305 | ||
311 | d->packet_size = packet_size; | 306 | d->packet_size = packet_size; |
312 | 307 | ||
@@ -337,47 +332,24 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, | |||
337 | } | 332 | } |
338 | } | 333 | } |
339 | 334 | ||
340 | d->buffer_status = kmalloc(d->num_desc * sizeof(unsigned int), | 335 | d->buffer_status = |
341 | GFP_KERNEL); | 336 | kzalloc(d->num_desc * sizeof(*d->buffer_status), GFP_KERNEL); |
342 | d->buffer_prg_assignment = kmalloc(d->num_desc * sizeof(unsigned int), | 337 | d->buffer_prg_assignment = |
343 | GFP_KERNEL); | 338 | kzalloc(d->num_desc * sizeof(*d->buffer_prg_assignment), GFP_KERNEL); |
344 | d->buffer_time = kmalloc(d->num_desc * sizeof(struct timeval), | 339 | d->buffer_time = |
345 | GFP_KERNEL); | 340 | kzalloc(d->num_desc * sizeof(*d->buffer_time), GFP_KERNEL); |
346 | d->last_used_cmd = kmalloc(d->num_desc * sizeof(unsigned int), | 341 | d->last_used_cmd = |
347 | GFP_KERNEL); | 342 | kzalloc(d->num_desc * sizeof(*d->last_used_cmd), GFP_KERNEL); |
348 | d->next_buffer = kmalloc(d->num_desc * sizeof(int), | 343 | d->next_buffer = |
349 | GFP_KERNEL); | 344 | kzalloc(d->num_desc * sizeof(*d->next_buffer), GFP_KERNEL); |
350 | 345 | ||
351 | if (d->buffer_status == NULL) { | 346 | if (!d->buffer_status || !d->buffer_prg_assignment || !d->buffer_time || |
352 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_status"); | 347 | !d->last_used_cmd || !d->next_buffer) { |
353 | free_dma_iso_ctx(d); | 348 | PRINT(KERN_ERR, ohci->host->id, |
354 | return NULL; | 349 | "Failed to allocate dma_iso_ctx member"); |
355 | } | ||
356 | if (d->buffer_prg_assignment == NULL) { | ||
357 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_prg_assignment"); | ||
358 | free_dma_iso_ctx(d); | ||
359 | return NULL; | ||
360 | } | ||
361 | if (d->buffer_time == NULL) { | ||
362 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_time"); | ||
363 | free_dma_iso_ctx(d); | ||
364 | return NULL; | ||
365 | } | ||
366 | if (d->last_used_cmd == NULL) { | ||
367 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate last_used_cmd"); | ||
368 | free_dma_iso_ctx(d); | ||
369 | return NULL; | ||
370 | } | ||
371 | if (d->next_buffer == NULL) { | ||
372 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate next_buffer"); | ||
373 | free_dma_iso_ctx(d); | 350 | free_dma_iso_ctx(d); |
374 | return NULL; | 351 | return NULL; |
375 | } | 352 | } |
376 | memset(d->buffer_status, 0, d->num_desc * sizeof(unsigned int)); | ||
377 | memset(d->buffer_prg_assignment, 0, d->num_desc * sizeof(unsigned int)); | ||
378 | memset(d->buffer_time, 0, d->num_desc * sizeof(struct timeval)); | ||
379 | memset(d->last_used_cmd, 0, d->num_desc * sizeof(unsigned int)); | ||
380 | memset(d->next_buffer, -1, d->num_desc * sizeof(int)); | ||
381 | 353 | ||
382 | spin_lock_init(&d->lock); | 354 | spin_lock_init(&d->lock); |
383 | 355 | ||
@@ -1085,7 +1057,7 @@ static int __video1394_ioctl(struct file *file, | |||
1085 | } | 1057 | } |
1086 | 1058 | ||
1087 | if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) { | 1059 | if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) { |
1088 | int buf_size = d->nb_cmd * sizeof(unsigned int); | 1060 | int buf_size = d->nb_cmd * sizeof(*psizes); |
1089 | struct video1394_queue_variable __user *p = argp; | 1061 | struct video1394_queue_variable __user *p = argp; |
1090 | unsigned int __user *qv; | 1062 | unsigned int __user *qv; |
1091 | 1063 | ||
@@ -1251,13 +1223,12 @@ static int video1394_open(struct inode *inode, struct file *file) | |||
1251 | if (ohci == NULL) | 1223 | if (ohci == NULL) |
1252 | return -EIO; | 1224 | return -EIO; |
1253 | 1225 | ||
1254 | ctx = kmalloc(sizeof(struct file_ctx), GFP_KERNEL); | 1226 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); |
1255 | if (ctx == NULL) { | 1227 | if (!ctx) { |
1256 | PRINT(KERN_ERR, ohci->host->id, "Cannot malloc file_ctx"); | 1228 | PRINT(KERN_ERR, ohci->host->id, "Cannot malloc file_ctx"); |
1257 | return -ENOMEM; | 1229 | return -ENOMEM; |
1258 | } | 1230 | } |
1259 | 1231 | ||
1260 | memset(ctx, 0, sizeof(struct file_ctx)); | ||
1261 | ctx->ohci = ohci; | 1232 | ctx->ohci = ohci; |
1262 | INIT_LIST_HEAD(&ctx->context_list); | 1233 | INIT_LIST_HEAD(&ctx->context_list); |
1263 | ctx->current_ctx = NULL; | 1234 | ctx->current_ctx = NULL; |