livepatch: robustify klp_register_patch() API error checking
[sfrench/cifs-2.6.git] / kernel / livepatch / core.c
index eb5db6e837aae1f0ba9c06b88f1903e0c3acc4bb..28c37fa3d3f951230ddafd1a2973ff7bd3d6bfe8 100644 (file)
@@ -876,6 +876,9 @@ int klp_register_patch(struct klp_patch *patch)
 {
        int ret;
 
+       if (!patch || !patch->mod)
+               return -EINVAL;
+
        if (!is_livepatch_module(patch->mod)) {
                pr_err("module %s is not marked as a livepatch module",
                       patch->mod->name);
@@ -885,9 +888,6 @@ int klp_register_patch(struct klp_patch *patch)
        if (!klp_initialized())
                return -ENODEV;
 
-       if (!patch || !patch->mod)
-               return -EINVAL;
-
        /*
         * A reference is taken on the patch module to prevent it from being
         * unloaded.  Right now, we don't allow patch modules to unload since