[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] handle some malloc failures



Here's a series of patches to fix or mark-with-comment uses
of malloc where a failure can lead to NULL dereference.
I started off fixing them, but there were pretty many,
so after a while I merely marked them.

Note I've marked a use of strdup, too.  While I went through
the entire list of uses of malloc, I haven't done the same
for strdup.  That was just the first one I spotted.

Jim

>From e0d6d82db2f6aa8029b6be2cbc387cef749b81af Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Mon, 13 Oct 2008 15:57:20 +0200
Subject: [PATCH] don't dereference NULL upon failed malloc

* cman/daemon/daemon.c (process_rendezvous):  Fix typo (s/con/newcon/)
that would make a failed realloc cause a NULL dereference.
---
 cman/daemon/daemon.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cman/daemon/daemon.c b/cman/daemon/daemon.c
index b08e78e..6cef080 100644
--- a/cman/daemon/daemon.c
+++ b/cman/daemon/daemon.c
@@ -329,7 +329,7 @@ static int process_rendezvous(poll_handle handle, int fd, int revent, void *data
 	client_fd = accept(fd, (struct sockaddr *) &socka, &sl);
 	if (client_fd >= 0) {
 		struct connection *newcon = malloc(sizeof(struct connection));
-		if (!con) {
+		if (!newcon) {
 			close(client_fd);
 			return 0; /* returning -1 will remove us */
 		}
-- 
1.6.0.2.514.g23abd3


>From 4c5232b19de55b706e060d7e59272f1851bd8930 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Mon, 13 Oct 2008 16:11:53 +0200
Subject: [PATCH] * cman/lib/libcman.c (cman_dispatch): Handle a failed malloc.

---
 cman/lib/libcman.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/cman/lib/libcman.c b/cman/lib/libcman.c
index bf6df83..9855c17 100644
--- a/cman/lib/libcman.c
+++ b/cman/lib/libcman.c
@@ -518,6 +518,8 @@ int cman_dispatch(cman_handle_t handle, int flags)
 		if (header->length > sizeof(buf))
 		{
 			bufptr = malloc(header->length);
+			if (!bufptr)
+				return -1;
 			memcpy(bufptr, buf, sizeof(*header));
 			header = (struct sock_header *)bufptr;
 		}
-- 
1.6.0.2.514.g23abd3


>From 43d3ff3bde54bf32de2d003ff7f767691690ba31 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Mon, 13 Oct 2008 16:21:31 +0200
Subject: [PATCH] * fence/agents/xvm/ip_lookup.c (add_ip): Handle malloc failure.

---
 fence/agents/xvm/ip_lookup.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fence/agents/xvm/ip_lookup.c b/fence/agents/xvm/ip_lookup.c
index 6500025..cbeb5b2 100644
--- a/fence/agents/xvm/ip_lookup.c
+++ b/fence/agents/xvm/ip_lookup.c
@@ -73,6 +73,8 @@ add_ip(ip_list_t *ipl, char *ipaddr, char family)
 	dbg_printf(4, "Adding IP %s to list (family %d)\n", ipaddr, family);

 	ipa = malloc(sizeof(*ipa));
+	if (!ipa)
+		return -1;
 	memset(ipa, 0, sizeof(*ipa));
 	ipa->ipa_family = family;
 	ipa->ipa_address = strdup(ipaddr);
-- 
1.6.0.2.514.g23abd3


>From c6ab824d5c46b016769dd95e96a4eb135feb2b98 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Mon, 13 Oct 2008 17:08:45 +0200
Subject: [PATCH] * gfs/gfs_fsck/inode.c (check_inode): handle failed malloc

---
 gfs/gfs_fsck/inode.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/gfs/gfs_fsck/inode.c b/gfs/gfs_fsck/inode.c
index 4420880..7a88589 100644
--- a/gfs/gfs_fsck/inode.c
+++ b/gfs/gfs_fsck/inode.c
@@ -125,7 +125,11 @@ static int fs_get_istruct(struct fsck_sb *sdp, struct gfs_inum *inum,
 		goto out;
 	}

-	ip = (struct fsck_inode *)malloc(sizeof(struct fsck_inode));
+	if(!(ip = (struct fsck_inode *)malloc(sizeof(struct fsck_inode)))) {
+		log_err("Unable to allocate memory for inode\n");
+		error = -1;
+		goto out;
+	}
 	ip->i_num = *inum;

 	ip->i_sbd = sdp;
-- 
1.6.0.2.514.g23abd3


>From df2d490961b836fdd129ed724376813908fc4b6c Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Mon, 13 Oct 2008 16:31:54 +0200
Subject: [PATCH] remove dead code (useless test of memset return value)

* gfs/gfs_fsck/block_list.c (block_list_create): memset can't fail.
There are many more like this.
---
 gfs/gfs_fsck/block_list.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/gfs/gfs_fsck/block_list.c b/gfs/gfs_fsck/block_list.c
index ecc9dbd..f377fd0 100644
--- a/gfs/gfs_fsck/block_list.c
+++ b/gfs/gfs_fsck/block_list.c
@@ -23,10 +23,7 @@ struct block_list *block_list_create(uint64_t size, enum block_list_type type)
 	log_info("Creating a block list of size %"PRIu64"...\n", size);

 	if ((il = malloc(sizeof(*il)))) {
-		if(!memset(il, 0, sizeof(*il))) {
-			log_err("Cannot set block list to zero\n");
-			return NULL;
-		}
+		memset(il, 0, sizeof(*il));
 		il->type = type;

 		switch(type) {
-- 
1.6.0.2.514.g23abd3


>From 71f475740de9c7bca1e958f9a7c8936b7a4a471d Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Mon, 13 Oct 2008 16:48:39 +0200
Subject: [PATCH] add comments marking unchecked malloc calls

* gfs/gfs_fsck/super.c:
* gfs/libgfs/fs_dir.c:
* gfs/libgfs/inode.c:
* gfs/libgfs/super.c (ji_update):
* gfs2/edit/hexedit.c (display_indirect):
* gfs2/edit/savemeta.c (gfs1_rindex_read):
* gfs2/fsck/initialize.c (init_system_inodes):
* gfs2/libgfs2/super.c (rindex_read):
* group/daemon/app.c:
* group/daemon/cpg.c (deliver_cb):
* group/daemon/joinleave.c (new_node):
* group/daemon/main.c (do_get_groups, do_send):
* group/dlm_controld/plock.c (unpack_section_buf):
* group/gfs_controld/plock.c (unpack_section_buf):
* src/daemons/clurmtabd_lib.c (rmtab_insert):
* src/daemons/dtest.c (dtest_shell, main):
---
 gfs/gfs_fsck/fs_dir.c                 |    4 ++++
 gfs/gfs_fsck/super.c                  |    3 +++
 gfs/libgfs/fs_dir.c                   |    4 ++++
 gfs/libgfs/inode.c                    |    1 +
 gfs/libgfs/super.c                    |    1 +
 gfs2/edit/hexedit.c                   |    1 +
 gfs2/edit/savemeta.c                  |    1 +
 gfs2/fsck/initialize.c                |    1 +
 gfs2/libgfs2/super.c                  |    1 +
 group/daemon/app.c                    |    3 +++
 group/daemon/cpg.c                    |    2 ++
 group/daemon/joinleave.c              |    1 +
 group/daemon/main.c                   |    2 ++
 group/dlm_controld/plock.c            |    2 ++
 group/gfs_controld/plock.c            |    2 ++
 rgmanager/src/daemons/clurmtabd_lib.c |    1 +
 rgmanager/src/daemons/dtest.c         |    2 ++
 17 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/gfs/gfs_fsck/fs_dir.c b/gfs/gfs_fsck/fs_dir.c
index 399575e..27f559a 100644
--- a/gfs/gfs_fsck/fs_dir.c
+++ b/gfs/gfs_fsck/fs_dir.c
@@ -549,6 +549,7 @@ static int dir_l_search(struct fsck_inode *dip, identifier_t *id, unsigned int *
 			exit(1);
 		}
 		id->inum = (struct gfs_inum *)malloc(sizeof(struct gfs_inum));
+		/* FIXME: don't dereference NULL on failed malloc */
 		memset(id->inum, 0, sizeof(struct gfs_inum));

 		gfs_inum_in(id->inum, (char *)&dent->de_inum);
@@ -558,10 +559,12 @@ static int dir_l_search(struct fsck_inode *dip, identifier_t *id, unsigned int *
 			exit(1);
 		}
 		id->filename = (osi_filename_t *)malloc(sizeof(osi_filename_t));
+		/* FIXME: don't dereference NULL on failed malloc */
 		memset(id->filename, 0, sizeof(osi_filename_t));

 		id->filename->len = gfs16_to_cpu(dent->de_name_len);
 		id->filename->name = malloc(id->filename->len);
+		/* FIXME: don't dereference NULL on failed malloc */
 		memset(id->filename->name, 0, id->filename->len);

 		memcpy(id->filename->name, (char *)dent+sizeof(struct gfs_dirent),
@@ -801,6 +804,7 @@ static int dir_split_leaf(struct fsck_inode *dip, uint32 index, uint64 leaf_no)
 	    This code is complicated enough already.  */

 	lp = (uint64 *)malloc(half_len * sizeof(uint64));
+	/* FIXME: don't dereference NULL on failed malloc */
 	memset(lp, 0, half_len * sizeof(uint64));

 	error = readi(dip, (char *)lp, start * sizeof(uint64),
diff --git a/gfs/gfs_fsck/super.c b/gfs/gfs_fsck/super.c
index b2c81f1..9c553f2 100644
--- a/gfs/gfs_fsck/super.c
+++ b/gfs/gfs_fsck/super.c
@@ -710,6 +710,7 @@ int gfs_rgindex_rebuild(struct fsck_sb *sdp, osi_list_t *ret_list,
 			/* ------------------------------------------------------------- */
 			/* Allocate a new RG and index. */
 			calc_rgd = (struct fsck_rgrp *)malloc(sizeof(struct fsck_rgrp));
+			/* FIXME: handle failed malloc */
 			memset(calc_rgd, 0, sizeof(struct fsck_rgrp));
 			calc_rgd->rd_sbd = sdp; /* hopefully this is not used */
 			osi_list_add_prev(&calc_rgd->rd_list, ret_list);
@@ -975,6 +976,7 @@ int gfs_rgindex_calculate(struct fsck_sb *sdp, osi_list_t *ret_list,
 				(rgs_per_subd - 1) * (adjust_subdevice_size / rgs_per_subd);
 		
 		calc_rgd = (struct fsck_rgrp *)malloc(sizeof(struct fsck_rgrp));
+		/* FIXME: handle failed malloc */
 		memset(calc_rgd, 0, sizeof(struct fsck_rgrp));
 		calc_rgd->rd_sbd = sdp; /* hopefully this is not used */
 		osi_list_add_prev(&calc_rgd->rd_list, ret_list);
@@ -1117,6 +1119,7 @@ int ri_update(struct fsck_sb *sdp)
 			}
 			
 			rgd = (struct fsck_rgrp *)malloc(sizeof(struct fsck_rgrp));
+			/* FIXME: handle failed malloc */
 			memset(rgd, 0, sizeof(struct fsck_rgrp));
 			rgd->rd_sbd = sdp;
 			osi_list_add_prev(&rgd->rd_list, &sdp->rglist);
diff --git a/gfs/libgfs/fs_dir.c b/gfs/libgfs/fs_dir.c
index 0d704d4..fe34b8a 100644
--- a/gfs/libgfs/fs_dir.c
+++ b/gfs/libgfs/fs_dir.c
@@ -544,6 +544,7 @@ static int dir_l_search(int disk_fd, struct gfs_inode *dip, identifier_t *id,
 			exit(1);
 		}
 		id->inum = (struct gfs_inum *)malloc(sizeof(struct gfs_inum));
+		/* FIXME: handle failed malloc */
 		memset(id->inum, 0, sizeof(struct gfs_inum));

 		gfs_inum_in(id->inum, (char *)&dent->de_inum);
@@ -553,10 +554,12 @@ static int dir_l_search(int disk_fd, struct gfs_inode *dip, identifier_t *id,
 			exit(1);
 		}
 		id->filename = (osi_filename_t *)malloc(sizeof(osi_filename_t));
+		/* FIXME: handle failed malloc */
 		memset(id->filename, 0, sizeof(osi_filename_t));

 		id->filename->len = gfs16_to_cpu(dent->de_name_len);
 		id->filename->name = malloc(id->filename->len);
+		/* FIXME: handle failed malloc */
 		memset(id->filename->name, 0, id->filename->len);

 		memcpy(id->filename->name, (char *)dent+sizeof(struct gfs_dirent),
@@ -798,6 +801,7 @@ static int dir_split_leaf(int disk_fd, struct gfs_inode *dip, uint32 index,
 	    This code is complicated enough already.  */

 	lp = (uint64 *)malloc(half_len * sizeof(uint64));
+	/* FIXME: handle failed malloc */
 	memset(lp, 0, half_len * sizeof(uint64));

 	error = readi(disk_fd, dip, (char *)lp, start * sizeof(uint64),
diff --git a/gfs/libgfs/inode.c b/gfs/libgfs/inode.c
index d7f4e53..b288ef6 100644
--- a/gfs/libgfs/inode.c
+++ b/gfs/libgfs/inode.c
@@ -122,6 +122,7 @@ static int fs_get_istruct(int disk_fd, struct gfs_sbd *sdp,
 	}

 	ip = (struct gfs_inode *)malloc(sizeof(struct gfs_inode));
+	/* FIXME: handle failed malloc */
 	ip->i_num = *inum;

 	ip->i_sbd = sdp;
diff --git a/gfs/libgfs/super.c b/gfs/libgfs/super.c
index afaf2bb..c479c27 100644
--- a/gfs/libgfs/super.c
+++ b/gfs/libgfs/super.c
@@ -344,6 +344,7 @@ int ri_update(int disk_fd, struct gfs_sbd *sdp)
 			goto fail;
 		}
 		rgd = (struct gfs_rgrpd *)malloc(sizeof(struct gfs_rgrpd));
+		/* FIXME: handle failed malloc */
 		rgd->rd_sbd = sdp;
 		osi_list_add_prev((osi_list_t *)&rgd->rd_list,
 						  (osi_list_t *)&sdp->sd_rglist);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 534d8cb..bc17d2e 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1259,6 +1259,7 @@ int display_indirect(struct iinfo *ind, int indblocks, int level, uint64_t start
 			char *tmpbuf;
 			
 			more_indir = malloc(sizeof(struct iinfo));
+			/* FIXME: handle failed malloc */
 			tmpbuf = malloc(sbd.bsize);
 			if (tmpbuf) {
 				do_lseek(sbd.device_fd,
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 693ac0f..a1523b3 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -292,6 +292,7 @@ int gfs1_rindex_read(struct gfs2_sbd *sdp, int fd, int *count1)
 			return -1;

 		rgd = (struct rgrp_list *)malloc(sizeof(struct rgrp_list));
+		/* FIXME: handle failed malloc */
 		memset(rgd, 0, sizeof(struct rgrp_list));
 		osi_list_add_prev(&rgd->list, &sdp->rglist);

diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 1d2df6a..bb395cb 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -212,6 +212,7 @@ static int init_system_inodes(struct gfs2_sbd *sdp)

 	gfs2_lookupi(sdp->master_dir, "statfs", 6, &sdp->md.statfs);
 	buf = malloc(sdp->md.statfs->i_di.di_size);
+	/* FIXME: handle failed malloc */
 	gfs2_readi(sdp->md.statfs, buf, 0, sdp->md.statfs->i_di.di_size);
 	/* call gfs2_inum_range_in() to retrieve range */
 	gfs2_statfs_change_in(&sc, buf);
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index 88708fe..c82221e 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -184,6 +184,7 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, int *count1)
 			return -1;

 		rgd = (struct rgrp_list *)malloc(sizeof(struct rgrp_list));
+		/* FIXME: handle failed malloc */
 		memset(rgd, 0, sizeof(struct rgrp_list));
 		osi_list_add_prev(&rgd->list, &sdp->rglist);

diff --git a/group/daemon/app.c b/group/daemon/app.c
index 30c11da..9ca2801 100644
--- a/group/daemon/app.c
+++ b/group/daemon/app.c
@@ -178,6 +178,7 @@ void extend_recover_event(group_t *g, event_t *ev, int nodeid)
 	}

 	id = malloc(sizeof(struct nodeid));
+	/* FIXME: handle failed malloc */
 	id->nodeid = new_id_nodeid;
 	list_add(&id->list, &ev->extended);
 }
@@ -274,6 +275,7 @@ struct recovery_set *add_recovery_set_cpg(int nodeid, int procdown)
 			if (node->nodeid == nodeid) {
 				log_group(g, "add to recovery set %d", nodeid);
 				re = malloc(sizeof(*re));
+				/* FIXME: handle failed malloc */
 				memset(re, 0, sizeof(struct recovery_entry));
 				re->group = g;
 				list_add_tail(&re->list, &rs->entries);
@@ -1534,6 +1536,7 @@ int recover_current_event(group_t *g)
 		}

 		id = malloc(sizeof(struct nodeid));
+		/* FIXME: handle failed malloc */
 		id->nodeid = rev->nodeid;
 		list_add(&id->list, &ev->extended);
 		log_group(g, "extend active rev %d with failed node %d",
diff --git a/group/daemon/cpg.c b/group/daemon/cpg.c
index aa3974b..6dd98cb 100644
--- a/group/daemon/cpg.c
+++ b/group/daemon/cpg.c
@@ -648,12 +648,14 @@ void deliver_cb(cpg_handle_t handle, struct cpg_name *group_name,
 			  msg_type(msg->ms_type), nodeid);

 	save = malloc(sizeof(struct save_msg));
+	/* FIXME: handle failed malloc */
 	memset(save, 0, sizeof(struct save_msg));
 	save->nodeid = nodeid;
 	save->msg_len = data_len;

 	if (data_len > sizeof(msg_t)) {
 		buf = malloc(data_len);
+		/* FIXME: handle failed malloc */
 		memcpy(buf, data, data_len);
 		save->msg_long = buf;
 		memcpy(&save->msg, data, sizeof(msg_t));
diff --git a/group/daemon/joinleave.c b/group/daemon/joinleave.c
index 4169392..95cc444 100644
--- a/group/daemon/joinleave.c
+++ b/group/daemon/joinleave.c
@@ -157,6 +157,7 @@ node_t *new_node(int nodeid)
 	node_t *node;

 	node = malloc(sizeof(*node));
+	/* FIXME: handle failed malloc */
 	memset(node, 0, sizeof(*node));
 	node->nodeid = nodeid;
 	return node;
diff --git a/group/daemon/main.c b/group/daemon/main.c
index c598307..c875f14 100644
--- a/group/daemon/main.c
+++ b/group/daemon/main.c
@@ -485,6 +485,7 @@ static int do_get_groups(int ci, int argc, char **argv)
 	int rv, count = 0, max = atoi(argv[1]);

 	data = malloc(sizeof(group_data_t));
+	/* FIXME: handle failed malloc */
 	count = 0;

 	list_for_each_entry(g, &gd_groups, list) {
@@ -588,6 +589,7 @@ static void do_send(char *name, int level, int len, char *data)

 	total = sizeof(msg_t) + len;
 	buf = malloc(total);
+	/* FIXME: handle failed malloc */
 	memset(buf, 0, total);

 	memcpy(buf + sizeof(msg_t), data, len);
diff --git a/group/dlm_controld/plock.c b/group/dlm_controld/plock.c
index 3a95caf..bb47b05 100644
--- a/group/dlm_controld/plock.c
+++ b/group/dlm_controld/plock.c
@@ -1618,6 +1618,7 @@ static int unpack_section_buf(struct lockspace *ls, char *numbuf, int buflen)
 	for (i = 0; i < count; i++) {
 		if (!pp->waiter) {
 			po = malloc(sizeof(struct posix_lock));
+			/* FIXME: handle failed malloc */
 			po->start	= le64_to_cpu(pp->start);
 			po->end		= le64_to_cpu(pp->end);
 			po->owner	= le64_to_cpu(pp->owner);
@@ -1627,6 +1628,7 @@ static int unpack_section_buf(struct lockspace *ls, char *numbuf, int buflen)
 			list_add_tail(&po->list, &r->locks);
 		} else {
 			w = malloc(sizeof(struct lock_waiter));
+			/* FIXME: handle failed malloc */
 			w->info.start	= le64_to_cpu(pp->start);
 			w->info.end	= le64_to_cpu(pp->end);
 			w->info.owner	= le64_to_cpu(pp->owner);
diff --git a/group/gfs_controld/plock.c b/group/gfs_controld/plock.c
index 0b485a2..c441b25 100644
--- a/group/gfs_controld/plock.c
+++ b/group/gfs_controld/plock.c
@@ -1836,6 +1836,7 @@ static int unpack_section_buf(struct mountgroup *mg, char *numbuf, int buflen)
 	for (i = 0; i < count; i++) {
 		if (!pp->waiter) {
 			po = malloc(sizeof(struct posix_lock));
+			/* FIXME: handle failed malloc */
 			po->start	= le64_to_cpu(pp->start);
 			po->end		= le64_to_cpu(pp->end);
 			po->owner	= le64_to_cpu(pp->owner);
@@ -1845,6 +1846,7 @@ static int unpack_section_buf(struct mountgroup *mg, char *numbuf, int buflen)
 			list_add_tail(&po->list, &r->locks);
 		} else {
 			w = malloc(sizeof(struct lock_waiter));
+			/* FIXME: handle failed malloc */
 			w->info.start	= le64_to_cpu(pp->start);
 			w->info.end	= le64_to_cpu(pp->end);
 			w->info.owner	= le64_to_cpu(pp->owner);
diff --git a/rgmanager/src/daemons/clurmtabd_lib.c b/rgmanager/src/daemons/clurmtabd_lib.c
index 7c869df..aa216a2 100644
--- a/rgmanager/src/daemons/clurmtabd_lib.c
+++ b/rgmanager/src/daemons/clurmtabd_lib.c
@@ -204,6 +204,7 @@ rmtab_insert(rmtab_node **head, rmtab_node *pre, char *host,

 	/* Copy in info */
 	rnew = malloc(sizeof(*rnew));
+	/* FIXME: handle failed malloc */
 	memset(rnew, 0, sizeof(*rnew));
 	rnew->rn_hostname = strdup(host);
 	rnew->rn_path = strdup(path);
diff --git a/rgmanager/src/daemons/dtest.c b/rgmanager/src/daemons/dtest.c
index 8ee27e5..a42eed1 100644
--- a/rgmanager/src/daemons/dtest.c
+++ b/rgmanager/src/daemons/dtest.c
@@ -274,6 +274,7 @@ dtest_shell(void)
 	dep_op_t *ops = NULL, *op;
 	
 	nodes = malloc(sizeof(int)*nodes_all_count);
+	/* FIXME: handle failed malloc */
 	
 	while (!done) {
 		
@@ -325,6 +326,7 @@ dtest_shell(void)
 					free(nodes_online);
 				
 				nodes_online = malloc(sizeof(int) * cnt);
+				/* FIXME: handle failed malloc */
 				
 				for (x = 0; x < cnt; x++)
 					nodes_online[x] = nodes[x];
-- 
1.6.0.2.514.g23abd3


>From 13ac364cc61333595c18a518f5140498e022a697 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Mon, 13 Oct 2008 17:21:54 +0200
Subject: [PATCH] Remove unused local variable, buf,

* gfs2/edit/savemeta.c (save_inode_data): ...along with malloc and free.
---
 gfs2/edit/savemeta.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index a1523b3..9587d58 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -583,11 +583,9 @@ void save_inode_data(int out_fd)
 	osi_list_t *prev_list, *cur_list, *tmp;
 	struct gfs2_buffer_head *metabh, *mybh;
 	int i;
-	char *buf;

 	for (i = 0; i < GFS2_MAX_META_HEIGHT; i++)
 		osi_list_init(&metalist[i]);
-	buf = malloc(sbd.bsize);
 	metabh = bread(&sbd, block);
 	inode = inode_get(&sbd, metabh);
 	height = inode->i_di.di_height;
@@ -662,7 +660,6 @@ void save_inode_data(int out_fd)
 		brelse(metabh, not_updated);
 	}
 	inode_put(inode, not_updated);
-	free(buf);
 }

 void get_journal_inode_blocks(void)
-- 
1.6.0.2.514.g23abd3


>From 4816b957b4cfc9b478522adfba238cb2a3c45404 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Mon, 13 Oct 2008 18:12:14 +0200
Subject: [PATCH] add comments marking unchecked strdup calls

* config/tools/ccs_tool/editconf.c (add_fence_args):
---
 config/tools/ccs_tool/editconf.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c
index 53b0ed6..28e24da 100644
--- a/config/tools/ccs_tool/editconf.c
+++ b/config/tools/ccs_tool/editconf.c
@@ -447,6 +447,7 @@ static void add_fence_args(xmlNode *fencenode, int argc, char **argv, int optind
 		char *equals;

 		prop = strdup(argv[i]);
+		/* FIXME: handle failed strdup */
 		equals = strchr(prop, '=');
 		if (!equals)
 			die("option '%s' is not opt=value pair\n", prop);
-- 
1.6.0.2.514.g23abd3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]