From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Cc: "Jorge Lopez" <jorge.lopez2@hp.com>,
"Hans de Goede" <hdegoede@redhat.com>,
"Mark Gross" <markgross@kernel.org>,
"Thomas Weißschuh" <linux@weissschuh.net>,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
dan.carpenter@linaro.org, kernel-janitors@vger.kernel.org,
error27@gmail.com, vegard.nossum@oracle.com,
darren.kenny@oracle.com, "kernel test robot" <lkp@intel.com>
Subject: Re: [PATCH v2 4/4] platform/x86: hp-bioscfg: Fix error handling in hp_add_other_attributes()
Date: Mon, 13 Nov 2023 16:15:50 +0200 (EET) [thread overview]
Message-ID: <a0b5d36a-aad8-eaf5-7241-85d1c874ff8@linux.intel.com> (raw)
In-Reply-To: <c3b821fb-5df1-4c58-99bc-f3e99a6d1d94@oracle.com>
[-- Attachment #1: Type: text/plain, Size: 2891 bytes --]
On Mon, 13 Nov 2023, Harshit Mogalapalli wrote:
> On 13/11/23 7:01 pm, Ilpo Järvinen wrote:
> > On Sat, 11 Nov 2023, Harshit Mogalapalli wrote:
> > > On 10/11/23 8:14 pm, Ilpo Järvinen wrote:
> > > > On Fri, 10 Nov 2023, Harshit Mogalapalli wrote:
> > > >
> > >
> > > Thanks for the review.
> > >
> > > > This changelog needs to be rewritten, it contains multiple errors. I
> > > > suppose even this patch could be split into two but I'll not be too
> > > > picky
> > > > here if you insist on fixing them in the same patch.
> > > >
> > >
> > > Any thoughts on how to split this into two patches ?
> > >
> > > I thought of fixing memory leak in separate patch, but that would add more
> > > code which should be removed when we move kobject_put() to the end.
> >
> Thanks for the suggestions.
>
> > I meant that in the first patch you fix add the missing kfree(). Then in
> > the second one, you correct kobject_put() + play with goto labels. There's
> > no extra code that needs to be added and then removed AFAICT.
> >
>
> This is the problem I am trying to explain:
>
> Let us say we do memory leak fixing in first patch:
>
> diff --git a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> index 351d782f3e96..7f29a746210e 100644
> --- a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> +++ b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> @@ -612,6 +612,7 @@ static int hp_add_other_attributes(int attr_type)
> default:
> pr_err("Error: Unknown attr_type: %d\n", attr_type);
> ret = -EINVAL;
> + kfree(attr_name_kobj);
> goto err_other_attr_init;
> }
>
> @@ -637,8 +638,10 @@ static int hp_add_other_attributes(int attr_type)
> ret = -EINVAL;
> }
>
> - if (ret)
> + if (ret) {
> + kfree(attr_name_kobj); ///// [1]
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
Solve each in own patch and don't mix the solutions.
I know both patches are needed to solve _both_ problems so it's fine to
have "still broken" intermediate state as long as you didn't make things
worse in the first patch which you didn't.
> goto err_other_attr_init;
> + }
>
> mutex_unlock(&bioscfg_drv.mutex);
> return 0;
>
> Now when we want to move kobject_put() to goto label in next patch,
> we should remove the kfree [1], as kobject_put() already does a kfree().
>
> If that sounds okay, I will split this into two patches, (first one, only
> fixing memory leak; and second one fixing missing kobject_put() calls on error
> paths)
--
i.
next prev parent reply other threads:[~2023-11-13 14:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-10 14:29 [PATCH v2 1/4] platform/x86: hp-bioscfg: Remove unused obj in hp_add_other_attributes() Harshit Mogalapalli
2023-11-10 14:29 ` [PATCH v2 2/4] platform/x86: hp-bioscfg: Simplify return check " Harshit Mogalapalli
2023-11-10 14:29 ` [PATCH v2 3/4] platform/x86: hp-bioscfg: move mutex_lock down " Harshit Mogalapalli
2023-11-10 14:35 ` Ilpo Järvinen
2023-11-10 14:29 ` [PATCH v2 4/4] platform/x86: hp-bioscfg: Fix error handling " Harshit Mogalapalli
2023-11-10 14:44 ` Ilpo Järvinen
2023-11-10 19:58 ` Harshit Mogalapalli
2023-11-13 13:31 ` Ilpo Järvinen
2023-11-13 13:57 ` Harshit Mogalapalli
2023-11-13 14:15 ` Ilpo Järvinen [this message]
2023-11-13 16:01 ` Dan Carpenter
2023-11-13 16:44 ` Ilpo Järvinen
2023-11-10 14:31 ` [PATCH v2 1/4] platform/x86: hp-bioscfg: Remove unused obj " Ilpo Järvinen
2023-11-10 14:45 ` Ilpo Järvinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a0b5d36a-aad8-eaf5-7241-85d1c874ff8@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=dan.carpenter@linaro.org \
--cc=darren.kenny@oracle.com \
--cc=error27@gmail.com \
--cc=harshit.m.mogalapalli@oracle.com \
--cc=hdegoede@redhat.com \
--cc=jorge.lopez2@hp.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=lkp@intel.com \
--cc=markgross@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=vegard.nossum@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox