aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/debugobjects.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index 37061ede8b81..bf2c8b1043d8 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -381,19 +381,21 @@ void debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr)
381 * debug_object_activate - debug checks when an object is activated 381 * debug_object_activate - debug checks when an object is activated
382 * @addr: address of the object 382 * @addr: address of the object
383 * @descr: pointer to an object specific debug description structure 383 * @descr: pointer to an object specific debug description structure
384 * Returns 0 for success, -EINVAL for check failed.
384 */ 385 */
385void debug_object_activate(void *addr, struct debug_obj_descr *descr) 386int debug_object_activate(void *addr, struct debug_obj_descr *descr)
386{ 387{
387 enum debug_obj_state state; 388 enum debug_obj_state state;
388 struct debug_bucket *db; 389 struct debug_bucket *db;
389 struct debug_obj *obj; 390 struct debug_obj *obj;
390 unsigned long flags; 391 unsigned long flags;
392 int ret;
391 struct debug_obj o = { .object = addr, 393 struct debug_obj o = { .object = addr,
392 .state = ODEBUG_STATE_NOTAVAILABLE, 394 .state = ODEBUG_STATE_NOTAVAILABLE,
393 .descr = descr }; 395 .descr = descr };
394 396
395 if (!debug_objects_enabled) 397 if (!debug_objects_enabled)
396 return; 398 return 0;
397 399
398 db = get_bucket((unsigned long) addr); 400 db = get_bucket((unsigned long) addr);
399 401
@@ -405,23 +407,26 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr)
405 case ODEBUG_STATE_INIT: 407 case ODEBUG_STATE_INIT:
406 case ODEBUG_STATE_INACTIVE: 408 case ODEBUG_STATE_INACTIVE:
407 obj->state = ODEBUG_STATE_ACTIVE; 409 obj->state = ODEBUG_STATE_ACTIVE;
410 ret = 0;
408 break; 411 break;
409 412
410 case ODEBUG_STATE_ACTIVE: 413 case ODEBUG_STATE_ACTIVE:
411 debug_print_object(obj, "activate"); 414 debug_print_object(obj, "activate");
412 state = obj->state; 415 state = obj->state;
413 raw_spin_unlock_irqrestore(&db->lock, flags); 416 raw_spin_unlock_irqrestore(&db->lock, flags);
414 debug_object_fixup(descr->fixup_activate, addr, state); 417 ret = debug_object_fixup(descr->fixup_activate, addr, state);
415 return; 418 return ret ? -EINVAL : 0;
416 419
417 case ODEBUG_STATE_DESTROYED: 420 case ODEBUG_STATE_DESTROYED:
418 debug_print_object(obj, "activate"); 421 debug_print_object(obj, "activate");
422 ret = -EINVAL;
419 break; 423 break;
420 default: 424 default:
425 ret = 0;
421 break; 426 break;
422 } 427 }
423 raw_spin_unlock_irqrestore(&db->lock, flags); 428 raw_spin_unlock_irqrestore(&db->lock, flags);
424 return; 429 return ret;
425 } 430 }
426 431
427 raw_spin_unlock_irqrestore(&db->lock, flags); 432 raw_spin_unlock_irqrestore(&db->lock, flags);
@@ -431,8 +436,11 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr)
431 * true or not. 436 * true or not.
432 */ 437 */
433 if (debug_object_fixup(descr->fixup_activate, addr, 438 if (debug_object_fixup(descr->fixup_activate, addr,
434 ODEBUG_STATE_NOTAVAILABLE)) 439 ODEBUG_STATE_NOTAVAILABLE)) {
435 debug_print_object(&o, "activate"); 440 debug_print_object(&o, "activate");
441 return -EINVAL;
442 }
443 return 0;
436} 444}
437 445
438/** 446/**