Commit 0ea27d9f authored by Dave Jones's avatar Dave Jones
Browse files

[AGPGART] Replace kmalloc+memset's with kzalloc's



Signed-off-by: default avatarDave Jones <davej@redhat.com>
parent 0ff541da
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -94,19 +94,16 @@ static int amd_create_gatt_pages(int nr_tables)
	int retval = 0;
	int i;

	tables = kmalloc((nr_tables + 1) * sizeof(struct amd_page_map *),
			 GFP_KERNEL);
	tables = kzalloc((nr_tables + 1) * sizeof(struct amd_page_map *),GFP_KERNEL);
	if (tables == NULL)
		return -ENOMEM;

	memset (tables, 0, sizeof(struct amd_page_map *) * (nr_tables + 1));
	for (i = 0; i < nr_tables; i++) {
		entry = kmalloc(sizeof(struct amd_page_map), GFP_KERNEL);
		entry = kzalloc(sizeof(struct amd_page_map), GFP_KERNEL);
		if (entry == NULL) {
			retval = -ENOMEM;
			break;
		}
		memset (entry, 0, sizeof(struct amd_page_map));
		tables[i] = entry;
		retval = amd_create_page_map(entry);
		if (retval != 0)
+2 −5
Original line number Diff line number Diff line
@@ -116,14 +116,12 @@ static int ati_create_gatt_pages(int nr_tables)
	int retval = 0;
	int i;

	tables = kmalloc((nr_tables + 1) * sizeof(ati_page_map *),
			 GFP_KERNEL);
	tables = kzalloc((nr_tables + 1) * sizeof(ati_page_map *),GFP_KERNEL);
	if (tables == NULL)
		return -ENOMEM;

	memset(tables, 0, sizeof(ati_page_map *) * (nr_tables + 1));
	for (i = 0; i < nr_tables; i++) {
		entry = kmalloc(sizeof(ati_page_map), GFP_KERNEL);
		entry = kzalloc(sizeof(ati_page_map), GFP_KERNEL);
		if (entry == NULL) {
			while (i>0) {
				kfree (tables[i-1]);
@@ -134,7 +132,6 @@ static int ati_create_gatt_pages(int nr_tables)
			retval = -ENOMEM;
			break;
		}
		memset(entry, 0, sizeof(ati_page_map));
		tables[i] = entry;
		retval = ati_create_page_map(entry);
		if (retval != 0) break;
+3 −3
Original line number Diff line number Diff line
@@ -222,12 +222,12 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge)

struct agp_bridge_data *agp_alloc_bridge(void)
{
	struct agp_bridge_data *bridge = kmalloc(sizeof(*bridge), GFP_KERNEL);
	struct agp_bridge_data *bridge;
	
	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
	if (!bridge)
		return NULL;

	memset(bridge, 0, sizeof(*bridge));
	atomic_set(&bridge->agp_in_use, 0);
	atomic_set(&bridge->current_memory_agp, 0);

+4 −11
Original line number Diff line number Diff line
@@ -189,13 +189,12 @@ static int agp_create_segment(struct agp_client *client, struct agp_region *regi
	struct agp_segment *user_seg;
	size_t i;

	seg = kmalloc((sizeof(struct agp_segment_priv) * region->seg_count), GFP_KERNEL);
	seg = kzalloc((sizeof(struct agp_segment_priv) * region->seg_count), GFP_KERNEL);
	if (seg == NULL) {
		kfree(region->seg_list);
		region->seg_list = NULL;
		return -ENOMEM;
	}
	memset(seg, 0, (sizeof(struct agp_segment_priv) * region->seg_count));
	user_seg = region->seg_list;

	for (i = 0; i < region->seg_count; i++) {
@@ -332,14 +331,11 @@ static struct agp_controller *agp_create_controller(pid_t id)
{
	struct agp_controller *controller;

	controller = kmalloc(sizeof(struct agp_controller), GFP_KERNEL);

	controller = kzalloc(sizeof(struct agp_controller), GFP_KERNEL);
	if (controller == NULL)
		return NULL;

	memset(controller, 0, sizeof(struct agp_controller));
	controller->pid = id;

	return controller;
}

@@ -540,12 +536,10 @@ static struct agp_client *agp_create_client(pid_t id)
{
	struct agp_client *new_client;

	new_client = kmalloc(sizeof(struct agp_client), GFP_KERNEL);

	new_client = kzalloc(sizeof(struct agp_client), GFP_KERNEL);
	if (new_client == NULL)
		return NULL;

	memset(new_client, 0, sizeof(struct agp_client));
	new_client->pid = id;
	agp_insert_client(new_client);
	return new_client;
@@ -709,11 +703,10 @@ static int agp_open(struct inode *inode, struct file *file)
	if (minor != AGPGART_MINOR)
		goto err_out;

	priv = kmalloc(sizeof(struct agp_file_private), GFP_KERNEL);
	priv = kzalloc(sizeof(struct agp_file_private), GFP_KERNEL);
	if (priv == NULL)
		goto err_out_nomem;

	memset(priv, 0, sizeof(struct agp_file_private));
	set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags);
	priv->my_pid = current->pid;

+1 −3
Original line number Diff line number Diff line
@@ -105,12 +105,10 @@ struct agp_memory *agp_create_memory(int scratch_pages)
{
	struct agp_memory *new;

	new = kmalloc(sizeof(struct agp_memory), GFP_KERNEL);

	new = kzalloc(sizeof(struct agp_memory), GFP_KERNEL);
	if (new == NULL)
		return NULL;

	memset(new, 0, sizeof(struct agp_memory));
	new->key = agp_get_key();

	if (new->key < 0) {
Loading