[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-newbie
Subject:    Incorrect usage of kobject_init_and_add?
From:       Machiry Aravind Kumar <makrvcs () gmail ! com>
Date:       2018-12-18 8:50:35
Message-ID: CAAwk1nK-VqVVFJFd3sXOJhwensKD2PL3iK3gCPWgmZ=bDRnpNw () mail ! gmail ! com
[Download RAW message or body]

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
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic