History

Merge branch 'for-4.1/core-noarch' into for-linus

Jiri Kosina committed 11 years ago

Commit bcf5d542 parents 8cb2c2d 2e3ac943 files · +23 −58Browse files

Showing the changes to kernel/livepatch (1 of 3 files). Show all

Unified · Split

kernel/livepatch/core.c+17−52
@@ -335,32 +335,20 @@ unlock: · 334 unmodified lines
335335 rcu_read_unlock();
336336 }
337337
338−static int klp_disable_func(struct klp_func *func)
338+static void klp_disable_func(struct klp_func *func)
339339 {
340340 struct klp_ops *ops;
341− int ret;
342−
343− if (WARN_ON(func->state != KLP_ENABLED))
344− return -EINVAL;
345341
346− if (WARN_ON(!func->old_addr))
347− return -EINVAL;
342+ WARN_ON(func->state != KLP_ENABLED);
343+ WARN_ON(!func->old_addr);
348344
349345 ops = klp_find_ops(func->old_addr);
350346 if (WARN_ON(!ops))
351− return -EINVAL;
347+ return;
352348
353349 if (list_is_singular(&ops->func_stack)) {
354− ret = unregister_ftrace_function(&ops->fops);
355− if (ret) {
356− pr_err("failed to unregister ftrace handler for function '%s' (%d)\n",
357− func->old_name, ret);
358− return ret;
359− }
360−
361− ret = ftrace_set_filter_ip(&ops->fops, func->old_addr, 1, 0);
362− if (ret)
363− pr_warn("function unregister succeeded but failed to clear the filter\n");
350+ WARN_ON(unregister_ftrace_function(&ops->fops));
351+ WARN_ON(ftrace_set_filter_ip(&ops->fops, func->old_addr, 1, 0));
364352
365353 list_del_rcu(&func->stack_node);
366354 list_del(&ops->node);
@@ -370,8 +358,6 @@ static int klp_disable_func(struct klp_func *func) · 3 unmodified lines
370358 }
371359
372360 func->state = KLP_DISABLED;
373−
374− return 0;
375361 }
376362
377363 static int klp_enable_func(struct klp_func *func)
@@ -432,23 +418,15 @@ err: · 54 unmodified lines
432418 return ret;
433419 }
434420
435−static int klp_disable_object(struct klp_object *obj)
421+static void klp_disable_object(struct klp_object *obj)
436422 {
437423 struct klp_func *func;
438− int ret;
439424
440− for (func = obj->funcs; func->old_name; func++) {
441− if (func->state != KLP_ENABLED)
442− continue;
443−
444− ret = klp_disable_func(func);
445− if (ret)
446− return ret;
447− }
425+ for (func = obj->funcs; func->old_name; func++)
426+ if (func->state == KLP_ENABLED)
427+ klp_disable_func(func);
448428
449429 obj->state = KLP_DISABLED;
450−
451− return 0;
452430 }
453431
454432 static int klp_enable_object(struct klp_object *obj)
@@ -464,22 +442,19 @@ static int klp_enable_object(struct klp_object *obj) · 9 unmodified lines
464442
465443 for (func = obj->funcs; func->old_name; func++) {
466444 ret = klp_enable_func(func);
467− if (ret)
468− goto unregister;
445+ if (ret) {
446+ klp_disable_object(obj);
447+ return ret;
448+ }
469449 }
470450 obj->state = KLP_ENABLED;
471451
472452 return 0;
473−
474−unregister:
475− WARN_ON(klp_disable_object(obj));
476− return ret;
477453 }
478454
479455 static int __klp_disable_patch(struct klp_patch *patch)
480456 {
481457 struct klp_object *obj;
482− int ret;
483458
484459 /* enforce stacking: only the last enabled patch can be disabled */
485460 if (!list_is_last(&patch->list, &klp_patches) &&
@@ -489,12 +464,8 @@ static int __klp_disable_patch(struct klp_patch *patch) · 3 unmodified lines
489464 pr_notice("disabling patch '%s'\n", patch->mod->name);
490465
491466 for (obj = patch->objs; obj->funcs; obj++) {
492− if (obj->state != KLP_ENABLED)
493− continue;
494−
495− ret = klp_disable_object(obj);
496− if (ret)
497− return ret;
467+ if (obj->state == KLP_ENABLED)
468+ klp_disable_object(obj);
498469 }
499470
500471 patch->state = KLP_DISABLED;
@@ -553,8 +524,6 @@ static int __klp_enable_patch(struct klp_patch *patch) · 52 unmodified lines
553524 pr_notice("enabling patch '%s'\n", patch->mod->name);
554525
555526 for (obj = patch->objs; obj->funcs; obj++) {
556− klp_find_object_module(obj);
557−
558527 if (!klp_is_object_loaded(obj))
559528 continue;
560529
@@ -945,7 +914,6 @@ static void klp_module_notify_going(struct klp_patch *patch, · 384 unmodified lines
945914 {
946915 struct module *pmod = patch->mod;
947916 struct module *mod = obj->mod;
948− int ret;
949917
950918 if (patch->state == KLP_DISABLED)
951919 goto disabled;
@@ -953,10 +921,7 @@ static void klp_module_notify_going(struct klp_patch *patch, · 1 unmodified line
953921 pr_notice("reverting patch '%s' on unloading module '%s'\n",
954922 pmod->name, mod->name);
955923
956− ret = klp_disable_object(obj);
957− if (ret)
958− pr_warn("failed to revert patch '%s' on module '%s' (%d)\n",
959− pmod->name, mod->name, ret);
924+ klp_disable_object(obj);
960925
961926 disabled:
962927 klp_free_object_loaded(obj);