Re: [PATCH v2 4/4] platform/x86: hp-bioscfg: Fix error handling in hp_add_other_attributes()

From: Dan Carpenter
Date: Mon Nov 13 2023 - 11:01:14 EST


On Mon, Nov 13, 2023 at 04:15:50PM +0200, Ilpo Järvinen wrote:
> This relates to the 2nd problem (missing kobject_put()) and will be
> covered by the other patch. Don't try to solve this in the first patch
> at all!
>
> There are two indepedent problems:
> - Before kobject_init_and_add(), kfree() is missing
> - After kobject_init_and_add(), kobject_put() is missing

It's the same problem, though. The attr_name_kobj is leaked on all the
error paths. It's just that it needs to be freed different ways
depending on where you are. To me splitting it up makes it harder to
review and I would not allow it in Staging. You can't fix half the
problem.

regards,
dan carpenter