Skip to content

Commit bde82ee

Browse files
Lu WeiRich Felker
authored andcommitted
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: 17be2d2 ("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>
1 parent 7fe859e commit bde82ee

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/sh/maple/maple.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,10 @@ static int __init maple_bus_init(void)
834834

835835
maple_queue_cache = KMEM_CACHE(maple_buffer, SLAB_HWCACHE_ALIGN);
836836

837-
if (!maple_queue_cache)
837+
if (!maple_queue_cache) {
838+
retval = -ENOMEM;
838839
goto cleanup_bothirqs;
840+
}
839841

840842
INIT_LIST_HEAD(&maple_waitq);
841843
INIT_LIST_HEAD(&maple_sentq);
@@ -848,6 +850,7 @@ static int __init maple_bus_init(void)
848850
if (!mdev[i]) {
849851
while (i-- > 0)
850852
maple_free_dev(mdev[i]);
853+
retval = -ENOMEM;
851854
goto cleanup_cache;
852855
}
853856
baseunits[i] = mdev[i];

0 commit comments

Comments
 (0)