linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Incorrect usage of kobject_init_and_add?
@ 2019-01-09 23:14 Machiry Aravind Kumar
  0 siblings, 0 replies; only message in thread
From: Machiry Aravind Kumar @ 2019-01-09 23:14 UTC (permalink / raw)
  To: linux-kernel

Hi all,

I see some discrepancy in how the function: kobject_init_and_add is
used in various places of the kernel.

According to the docs, when kobject_init_and_add fails, the caller is
supposed to call kobject_put on the corresponding kobj.

We found several instances where this is indeed true:
https://elixir.bootlin.com/linux/latest/source/drivers/block/pktcdvd.c#L131

However, there are again several places where this is not the case.
For instance: https://github.com/torvalds/linux/blob/master/kernel/sched/cpufreq_schedutil.c#L754

Why is this discrepancy? Should these be fixed to add kobject_put in
their error path?

-Best,
Aravind

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-01-09 23:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-09 23:14 Incorrect usage of kobject_init_and_add? Machiry Aravind Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).