Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75af271e authored by Dan Carpenter's avatar Dan Carpenter Committed by David Teigland
Browse files

dlm: NULL dereference on failure in kmem_cache_create()



We aren't allowed to pass NULL pointers to kmem_cache_destroy() so if
both allocations fail, it leads to a NULL dereference.

Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent 1a058f52
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -21,21 +21,19 @@ static struct kmem_cache *rsb_cache;

int __init dlm_memory_init(void)
{
	int ret = 0;

	lkb_cache = kmem_cache_create("dlm_lkb", sizeof(struct dlm_lkb),
				__alignof__(struct dlm_lkb), 0, NULL);
	if (!lkb_cache)
		ret = -ENOMEM;
		return -ENOMEM;

	rsb_cache = kmem_cache_create("dlm_rsb", sizeof(struct dlm_rsb),
				__alignof__(struct dlm_rsb), 0, NULL);
	if (!rsb_cache) {
		kmem_cache_destroy(lkb_cache);
		ret = -ENOMEM;
		return -ENOMEM;
	}

	return ret;
	return 0;
}

void dlm_memory_exit(void)