* Hi (Assigning NULL to variable after freeing it).
@ 2018-01-17 10:44 Jose Bale
2018-01-17 11:01 ` Fwd: " Jose Bale
2018-01-17 18:44 ` Randy Dunlap
0 siblings, 2 replies; 3+ messages in thread
From: Jose Bale @ 2018-01-17 10:44 UTC (permalink / raw)
To: linux-kernel
Hi All,
I have just started to contribute to linux kernel. I was thinking of
giving a patch where a variable is made null after free if not already
done.
Some thing like this:
Original code:
kfree(x);
...........some other code...........
I will change this code to:
New code:
kfree(x);
++ x = NULL;
...........some other code...........
Will this kind of code change be accepted by linux kernel?
Also, isn't doing this a better practice - that is, assigning NULL to
variable after freeing it? What is the best practice? What do people
think about it?
Any feedback / replies will be greatly appreciated.
Regards,
JB
^ permalink raw reply [flat|nested] 3+ messages in thread
* Fwd: Hi (Assigning NULL to variable after freeing it).
2018-01-17 10:44 Hi (Assigning NULL to variable after freeing it) Jose Bale
@ 2018-01-17 11:01 ` Jose Bale
2018-01-17 18:44 ` Randy Dunlap
1 sibling, 0 replies; 3+ messages in thread
From: Jose Bale @ 2018-01-17 11:01 UTC (permalink / raw)
To: linux-kernel
Hi All,
I have just started to contribute to linux kernel. I was thinking of
giving a patch where a variable is made null after free if not already
done.
Some thing like this:
Original code:
kfree(x);
...........some other code...........
I will change this code to:
New code:
kfree(x);
++ x = NULL;
...........some other code...........
Will this kind of code change be accepted by linux kernel?
Also, isn't doing this a better practice - that is, assigning NULL to
variable after freeing it? What is the best practice? What do people
think about it?
Any feedback / replies will be greatly appreciated.
Regards,
JB
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Hi (Assigning NULL to variable after freeing it).
2018-01-17 10:44 Hi (Assigning NULL to variable after freeing it) Jose Bale
2018-01-17 11:01 ` Fwd: " Jose Bale
@ 2018-01-17 18:44 ` Randy Dunlap
1 sibling, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2018-01-17 18:44 UTC (permalink / raw)
To: Jose Bale, linux-kernel
On 01/17/18 02:44, Jose Bale wrote:
> Hi All,
>
> I have just started to contribute to linux kernel. I was thinking of
> giving a patch where a variable is made null after free if not already
> done.
>
> Some thing like this:
> Original code:
> kfree(x);
> ...........some other code...........
>
> I will change this code to:
> New code:
> kfree(x);
> ++ x = NULL;
> ...........some other code...........
>
> Will this kind of code change be accepted by linux kernel?
>
> Also, isn't doing this a better practice - that is, assigning NULL to
> variable after freeing it? What is the best practice? What do people
> think about it?
>
> Any feedback / replies will be greatly appreciated.
General answer is no... unless that particular code expects a freed pointer
to be null. In many cases the code is written so that this isn't needed,
so you would have to check each usage on a case-by-case basis.
Probably best to find something else to patch.
--
~Randy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-17 18:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-17 10:44 Hi (Assigning NULL to variable after freeing it) Jose Bale
2018-01-17 11:01 ` Fwd: " Jose Bale
2018-01-17 18:44 ` Randy Dunlap
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).