From f326ea63ecc683b3dc88d8ee4f598598d4ed3b39 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 1 Apr 2023 12:09:26 +0200 Subject: [PATCH] driver core: class: fix slab-use-after-free Read in class_register() Syzbot found that we had forgotten to unregister the lock_class_key when using it in commit dcfbb67e48a2 ("driver core: class: use lock_class_key already present in struct subsys_private") so fix that up and correctly release it when done. Cc: "Rafael J. Wysocki" Reported-and-tested-by: Fixes: dcfbb67e48a2 ("driver core: class: use lock_class_key already present in struct subsys_private") Link: https://lore.kernel.org/r/2023040126-blandness-duckling-bd55@gregkh Signed-off-by: Greg Kroah-Hartman --- drivers/base/class.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/base/class.c b/drivers/base/class.c index 06b96d6faa19..65502bd7d5c5 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -103,6 +103,7 @@ static void class_release(struct kobject *kobj) pr_debug("class '%s' does not have a release() function, " "be careful\n", class->name); + lockdep_unregister_key(&cp->lock_key); kfree(cp); }