Commit fc54cb8d authored by Li Qiong's avatar Li Qiong Committed by Ilya Dryomov
Browse files

libceph: check pointer before assigned to "c->rules[]"



It should be better to check pointer firstly, then assign it
to c->rules[]. Refine code a little bit.

Signed-off-by: default avatarLi Qiong <liqiong@nfschina.com>
Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 48490776
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -571,10 +571,10 @@ static struct crush_map *crush_decode(void *pbyval, void *end)
			goto bad;
#endif
		r = kmalloc(struct_size(r, steps, yes), GFP_NOFS);
		c->rules[i] = r;
		if (r == NULL)
			goto badmem;
		dout(" rule %d is at %p\n", i, r);
		c->rules[i] = r;
		r->len = yes;
		ceph_decode_copy_safe(p, end, &r->mask, 4, bad); /* 4 u8's */
		ceph_decode_need(p, end, r->len*3*sizeof(u32), bad);