Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

maple: fix wrong return value of maple_bus_init().

If KMEM_CACHE or maple_alloc_dev failed, the maple_bus_init() will return 0
rather than error, because the retval is not changed after KMEM_CACHE or
maple_alloc_dev failed.

Fixes: 17be2d2b1c33 ("sh: Add maple bus support for the SEGA Dreamcast.")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Lu Wei <luwei32@huawei.com>
Acked-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Rich Felker <dalias@libc.org>

authored by

Lu Wei and committed by
Rich Felker
bde82ee3 7fe859ee

+4 -1
+4 -1
drivers/sh/maple/maple.c
··· 834 834 835 835 maple_queue_cache = KMEM_CACHE(maple_buffer, SLAB_HWCACHE_ALIGN); 836 836 837 - if (!maple_queue_cache) 837 + if (!maple_queue_cache) { 838 + retval = -ENOMEM; 838 839 goto cleanup_bothirqs; 840 + } 839 841 840 842 INIT_LIST_HEAD(&maple_waitq); 841 843 INIT_LIST_HEAD(&maple_sentq); ··· 850 848 if (!mdev[i]) { 851 849 while (i-- > 0) 852 850 maple_free_dev(mdev[i]); 851 + retval = -ENOMEM; 853 852 goto cleanup_cache; 854 853 } 855 854 baseunits[i] = mdev[i];