[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH] lib/devfs: device_create(): Return NULL on errors



Instead of crashing the system, return NULL on device_create().

Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
---
 lib/devfs/device.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/devfs/device.c b/lib/devfs/device.c
index 044073a4..d67aee4a 100644
--- a/lib/devfs/device.c
+++ b/lib/devfs/device.c
@@ -155,8 +155,11 @@ device_create(struct driver *drv, const char *name, int 
flags)
        /*
         * Allocate a device structure.
         */
-       if ((dev = malloc(sizeof(struct device))) == NULL)
-               UK_CRASH("device_create");
+       dev = malloc(sizeof(struct device));
+       if (!dev) {
+               uk_pr_err("Failed to allocate device memory, creation 
failed\n");
+               return NULL;
+       }
 
        dev->driver = drv;
        device_register(dev, name, flags);
-- 
2.20.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.