linux-stable/include/linux/device
Greg Kroah-Hartman ddaf098ea7 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: syzbot+e7afd76ad060fa0d2605@syzkaller.appspotmail.com
Fixes: 7b884b7f24 ("driver core: class.c: convert to only use class_to_subsys")
Reported-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Cc: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Tested-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Link: https://lore.kernel.org/r/2023051610-stove-condense-9a77@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-19 11:03:36 +01:00
..
bus.h driver core: bus: move documentation for lock_key to proper location. 2023-03-25 09:38:08 +01:00
class.h driver core: class: properly reference count class_dev_iter() 2023-05-19 11:03:36 +01:00
driver.h driver core: driver.h: remove extern from function prototypes 2023-03-24 15:35:42 +01:00