diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index cb3cda1390ad..c5b8883599e3 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c @@ -1956,6 +1956,7 @@ dbAllocDmapLev(struct bmap * bmp, { s64 blkno; int leafidx, rc; + dmtree_t *tp = (dmtree_t *) &dp->tree; /* can't be more than a dmaps worth of blocks */ assert(l2nb <= L2BPERDMAP); @@ -1964,10 +1965,10 @@ dbAllocDmapLev(struct bmap * bmp, * free space. if sufficient free space is found, dbFindLeaf() * returns the index of the leaf at which free space was found. */ - if (dbFindLeaf((dmtree_t *) &dp->tree, l2nb, &leafidx, false)) + if (dbFindLeaf(tp, l2nb, &leafidx, false)) return -ENOSPC; - if (leafidx < 0) + if (leafidx < 0 || le32_to_cpu(tp->dmt_leafidx) < 0) return -EIO; /* determine the block number within the file system corresponding