diff mbox series

um: Fix return value in ubd_init()

Message ID 20240306091259.18605-1-duoming@zju.edu.cn
State New
Headers show
Series um: Fix return value in ubd_init() | expand

Commit Message

Duoming Zhou March 6, 2024, 9:12 a.m. UTC
When kmalloc_array() fails to allocate memory, the ubd_init()
should return -ENOMEM instead of -1. So, fix it.

Fixes: f88f0bdfc32f ("um: UBD Improvements")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
---
 arch/um/drivers/ubd_kern.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Johannes Berg March 28, 2024, 8:27 a.m. UTC | #1
On Wed, 2024-03-06 at 17:12 +0800, Duoming Zhou wrote:
> When kmalloc_array() fails to allocate memory, the ubd_init()
> should return -ENOMEM instead of -1. So, fix it.

Not sure this really matters, but the code seems cleaner with it :)

Reviewed-by: Johannes Berg <johannes@sipsolutions.net>

johannes
diff mbox series

Patch

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 92ee2697ff3..85e33caf62a 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1098,7 +1098,7 @@  static int __init ubd_init(void)
 
 	if (irq_req_buffer == NULL) {
 		printk(KERN_ERR "Failed to initialize ubd buffering\n");
-		return -1;
+		return -ENOMEM;
 	}
 	io_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE,
 				      sizeof(struct io_thread_req *),
@@ -1109,7 +1109,7 @@  static int __init ubd_init(void)
 
 	if (io_req_buffer == NULL) {
 		printk(KERN_ERR "Failed to initialize ubd buffering\n");
-		return -1;
+		return -ENOMEM;
 	}
 	platform_driver_register(&ubd_driver);
 	mutex_lock(&ubd_lock);