Skip to content
Commit ddaf098e authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

driver core: class: properly reference count class_dev_iter()



When class_dev_iter is initialized, the reference count for the subsys
private structure is incremented, but never decremented, causing a
memory leak over time.  To resolve this, save off a pointer to the
internal structure into the class_dev_iter structure and then when the
iterator is finished, drop the reference count.

Reported-and-tested-by: default avatar <syzbot+e7afd76ad060fa0d2605@syzkaller.appspotmail.com>
Fixes: 7b884b7f ("driver core: class.c: convert to only use class_to_subsys")
Reported-by: default avatarMirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Cc: Alan Stern <stern@rowland.harvard.edu>
Acked-by: default avatarRafael J. Wysocki <rafael@kernel.org>
Tested-by: default avatarMirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Link: https://lore.kernel.org/r/2023051610-stove-condense-9a77@gregkh


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1e94be78
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment