Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8551158a authored by Stefan Richter's avatar Stefan Richter Committed by Jody McIntyre
Browse files

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: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: default avatarJody McIntyre <scjody@modernduck.com>
parent 7afa1467
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -1261,7 +1261,7 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr)
		return CSR1212_EINVAL;
#endif

	cr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region));
	cr = CSR1212_MALLOC(sizeof(*cr));
	if (!cr)
		return CSR1212_ENOMEM;

@@ -1393,8 +1393,7 @@ int csr1212_parse_keyval(struct csr1212_keyval *kv,
	case CSR1212_KV_TYPE_LEAF:
		if (kv->key.id != CSR1212_KV_ID_EXTENDED_ROM) {
			kv->value.leaf.data = CSR1212_MALLOC(quads_to_bytes(kvi_len));
			if (!kv->value.leaf.data)
			{
			if (!kv->value.leaf.data) {
				ret = CSR1212_ENOMEM;
				goto fail;
			}
@@ -1462,7 +1461,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
		cache->next = NULL;
		csr->cache_tail = cache;
		cache->filled_head =
			CSR1212_MALLOC(sizeof(struct csr1212_cache_region));
			CSR1212_MALLOC(sizeof(*cache->filled_head));
		if (!cache->filled_head) {
			return CSR1212_ENOMEM;
		}
@@ -1484,7 +1483,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
	/* Now seach read portions of the cache to see if it is there. */
	for (cr = cache->filled_head; cr; cr = cr->next) {
		if (cache_index < cr->offset_start) {
			newcr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region));
			newcr = CSR1212_MALLOC(sizeof(*newcr));
			if (!newcr)
				return CSR1212_ENOMEM;

@@ -1508,7 +1507,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)

	if (!cr) {
		cr = cache->filled_tail;
		newcr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region));
		newcr = CSR1212_MALLOC(sizeof(*newcr));
		if (!newcr)
			return CSR1212_ENOMEM;

+1 −1
Original line number Diff line number Diff line
@@ -646,7 +646,7 @@ static inline struct csr1212_csr_rom_cache *csr1212_rom_cache_malloc(u_int32_t o
{
	struct csr1212_csr_rom_cache *cache;

	cache = CSR1212_MALLOC(sizeof(struct csr1212_csr_rom_cache) + size);
	cache = CSR1212_MALLOC(sizeof(*cache) + size);
	if (!cache)
		return NULL;

+1 −3
Original line number Diff line number Diff line
@@ -2218,14 +2218,12 @@ static int dv1394_init(struct ti_ohci *ohci, enum pal_or_ntsc format, enum modes
	unsigned long flags;
	int i;

	video = kmalloc(sizeof(struct video_card), GFP_KERNEL);
	video = kzalloc(sizeof(*video), GFP_KERNEL);
	if (!video) {
		printk(KERN_ERR "dv1394: cannot allocate video_card\n");
		goto err;
	}

	memset(video, 0, sizeof(struct video_card));

	video->ohci = ohci;
	/* lower 2 bits of id indicate which of four "plugs"
	   per host */
+6 −6
Original line number Diff line number Diff line
@@ -352,12 +352,12 @@ static int eth1394_probe(struct device *dev)
	if (!hi)
		return -ENOENT;

	new_node = kmalloc(sizeof(struct eth1394_node_ref),
	new_node = kmalloc(sizeof(*new_node),
			   in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
	if (!new_node)
		return -ENOMEM;

	node_info = kmalloc(sizeof(struct eth1394_node_info),
	node_info = kmalloc(sizeof(*node_info),
			    in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
	if (!node_info) {
		kfree(new_node);
@@ -433,12 +433,12 @@ static int eth1394_update(struct unit_directory *ud)
	node = eth1394_find_node(&priv->ip_node_list, ud);

	if (!node) {
		node = kmalloc(sizeof(struct eth1394_node_ref),
		node = kmalloc(sizeof(*node),
			       in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
		if (!node)
			return -ENOMEM;

		node_info = kmalloc(sizeof(struct eth1394_node_info),
		node_info = kmalloc(sizeof(*node_info),
				    in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
		if (!node_info) {
			kfree(node);
@@ -1014,7 +1014,7 @@ static inline int new_fragment(struct list_head *frag_info, int offset, int len)
		}
	}

	new = kmalloc(sizeof(struct fragment_info), GFP_ATOMIC);
	new = kmalloc(sizeof(*new), GFP_ATOMIC);
	if (!new)
		return -ENOMEM;

@@ -1033,7 +1033,7 @@ static inline int new_partial_datagram(struct net_device *dev,
{
	struct partial_datagram *new;

	new = kmalloc(sizeof(struct partial_datagram), GFP_ATOMIC);
	new = kmalloc(sizeof(*new), GFP_ATOMIC);
	if (!new)
		return -ENOMEM;

+6 −12
Original line number Diff line number Diff line
@@ -101,12 +101,10 @@ void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
		return NULL;
	}

	hi = kmalloc(sizeof(*hi) + data_size, GFP_ATOMIC);
	hi = kzalloc(sizeof(*hi) + data_size, GFP_ATOMIC);
	if (!hi)
		return NULL;

	memset(hi, 0, sizeof(*hi) + data_size);

	if (data_size) {
		data = hi->data = hi + 1;
		hi->size = data_size;
@@ -326,11 +324,9 @@ u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl,
		return retval;
	}

	as = (struct hpsb_address_serve *)
		kmalloc(sizeof(struct hpsb_address_serve), GFP_KERNEL);
	if (as == NULL) {
	as = kmalloc(sizeof(*as), GFP_KERNEL);
	if (!as)
		return retval;
	}

	INIT_LIST_HEAD(&as->host_list);
	INIT_LIST_HEAD(&as->hl_list);
@@ -383,11 +379,9 @@ int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
                return 0;
        }

        as = (struct hpsb_address_serve *)
                kmalloc(sizeof(struct hpsb_address_serve), GFP_ATOMIC);
        if (as == NULL) {
	as = kmalloc(sizeof(*as), GFP_ATOMIC);
	if (!as)
		return 0;
        }

        INIT_LIST_HEAD(&as->host_list);
        INIT_LIST_HEAD(&as->hl_list);
Loading