msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
 
        if (!msg_context)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        msg_context->instance = instance;
        msg_context->handle =
 
        if (!msg_context->handle) {
                kfree(msg_context);
-               return NULL;
+               return ERR_PTR(-ENOMEM);
        }
 
        return msg_context;
 
        /* get context */
        msg_context = get_msg_context(instance);
-       if (!msg_context) {
-               ret = -ENOMEM;
+       if (IS_ERR(msg_context)) {
+               ret = PTR_ERR(msg_context);
                goto unlock;
        }
 
        }
 
        msg_context = get_msg_context(instance);
-       if (!msg_context)
-               return -ENOMEM;
+       if (IS_ERR(msg_context))
+               return PTR_ERR(msg_context);
 
        init_completion(&msg_context->u.sync.cmplt);