public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: A <amit234234234234@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Setting variable NULL after freeing it.
Date: Sat, 12 Nov 2022 12:34:10 +0100	[thread overview]
Message-ID: <20221112113410.GA5553@1wt.eu> (raw)
In-Reply-To: <CAOM0=daopCt=LthGStL2zHYxgQ6iphLLfKZjxcPS07yCvyq42Q@mail.gmail.com>

On Sat, Nov 12, 2022 at 04:18:37PM +0530, A wrote:
> >
> > It depends. What's important is not to let a pointer exist to a freed
> > location, so if you're doing:
> >
> >     kfree(card->pool);
> >
> > then it's usually important to follow this by:
> >
> >     card->pool = NULL;
> >
> 
> I checked in kernel but at many places this is not being done. I can
> change all that code. But, will the patch be accepted?
> 
> So, if someone is doing -
> 
> kfree(x)
> ._some_code_
> ._some_code_
> ._some_code_
> 
> Then I can change it to -
> 
> kfree(x)
> x = NULL;
> ._some_code_
> ._some_code_
> ._some_code_
> 
> But, will the patch be accepted for this change?

I don't think so, for the reasons I explained previously,
unless you spot real bugs there during your reviews, of
course. Better focus on your own driver for now in my
opinion.

Willy

  reply	other threads:[~2022-11-12 11:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-12  6:17 Setting variable NULL after freeing it A
2022-11-12  7:47 ` Willy Tarreau
2022-11-12 10:48   ` A
2022-11-12 11:34     ` Willy Tarreau [this message]
2022-11-12 11:58       ` A
2022-11-12 12:01         ` Willy Tarreau
2022-11-12 12:15           ` A

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=20221112113410.GA5553@1wt.eu \
    --to=w@1wt.eu \
    --cc=amit234234234234@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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