From: Andrew Price Date: Fri, 6 Jan 2012 15:19:24 +0000 Subject: [Cluster-devel] [PATCH 05/11] gfs2_edit: Fix null pointer dereference in dump_journal In-Reply-To: <1325863170-32530-1-git-send-email-anprice@redhat.com> References: <1325863170-32530-1-git-send-email-anprice@redhat.com> Message-ID: <1325863170-32530-5-git-send-email-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Spotted by coverity: Dereferencing a pointer that might be null "(void *)jbuf" when calling "fsck_readi" Signed-off-by: Andrew Price --- gfs2/edit/hexedit.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index b05a7d6..7a17c04 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -2672,6 +2672,10 @@ static void dump_journal(const char *journal) j_bh = bread(&sbd, jblock); j_inode = inode_get(&sbd, j_bh); jbuf = malloc(sbd.bsize); + if (jbuf == NULL) { + fprintf(stderr, "Out of memory\n"); + exit(-1); + } } for (jb = 0; jb < j_size; jb += (sbd.gfs1 ? 1:sbd.bsize)) { -- 1.7.6.4