smatch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2 net] ice: Fix freeing uninitialized pointers
       [not found] <0efe132b-b343-4438-bb00-5a4b82722ed3@moroto.mountain>
@ 2024-03-23 16:56 ` Markus Elfring
  2024-03-24 10:43   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2024-03-23 16:56 UTC (permalink / raw
  To: Dan Carpenter, kernel-janitors, netdev, intel-wired-lan, smatch
  Cc: LKML, Alexander Lobakin, Andy Shevchenko, David Laight,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Jesse Brandeburg,
	Jiri Pirko, Jonathan Cameron, Julia Lawall, Kees Cook,
	Lukasz Czapnik, Paolo Abeni, Pucha Himasekhar Reddy, Dan Williams,
	Maciej Fijalkowski, Przemek Kitszel, Tony Nguyen

> Automatically cleaned up pointers need to be initialized before exiting
> their scope.  In this case, they need to be initialized to NULL before
> any return statement.

* May we expect that compilers should report that affected variables
  were only declared here instead of appropriately defined
  (despite of attempts for scope-based resource management)?

* Did you extend detection support in the source code analysis tool “Smatch”
  for a questionable implementation detail?


Regards,
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 net] ice: Fix freeing uninitialized pointers
  2024-03-23 16:56 ` [PATCH v2 net] ice: Fix freeing uninitialized pointers Markus Elfring
@ 2024-03-24 10:43   ` Dan Carpenter
  2024-03-24 13:22     ` [v2] " Markus Elfring
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2024-03-24 10:43 UTC (permalink / raw
  To: Markus Elfring
  Cc: kernel-janitors, netdev, intel-wired-lan, smatch, LKML,
	Alexander Lobakin, Andy Shevchenko, David Laight, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Jesse Brandeburg, Jiri Pirko,
	Jonathan Cameron, Julia Lawall, Kees Cook, Lukasz Czapnik,
	Paolo Abeni, Pucha Himasekhar Reddy, Dan Williams,
	Maciej Fijalkowski, Przemek Kitszel, Tony Nguyen

On Sat, Mar 23, 2024 at 05:56:29PM +0100, Markus Elfring wrote:
> > Automatically cleaned up pointers need to be initialized before exiting
> > their scope.  In this case, they need to be initialized to NULL before
> > any return statement.
> 
> * May we expect that compilers should report that affected variables
>   were only declared here instead of appropriately defined
>   (despite of attempts for scope-based resource management)?
> 

We disabled GCC's check for uninitialized variables a long time ago
because it had too many false positives.

> * Did you extend detection support in the source code analysis tool “Smatch”
>   for a questionable implementation detail?

Yes.  Smatch detects this as an uninitialized variable.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [v2] ice: Fix freeing uninitialized pointers
  2024-03-24 10:43   ` Dan Carpenter
@ 2024-03-24 13:22     ` Markus Elfring
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2024-03-24 13:22 UTC (permalink / raw
  To: Dan Carpenter, kernel-janitors, netdev, intel-wired-lan, smatch
  Cc: LKML, Alexander Lobakin, Andy Shevchenko, David Laight,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Jesse Brandeburg,
	Jiri Pirko, Jonathan Cameron, Julia Lawall, Kees Cook,
	Lukasz Czapnik, Paolo Abeni, Pucha Himasekhar Reddy, Dan Williams,
	Maciej Fijalkowski, Przemek Kitszel, Tony Nguyen

>>> Automatically cleaned up pointers need to be initialized before exiting
>>> their scope.  In this case, they need to be initialized to NULL before
>>> any return statement.
>>
>> * May we expect that compilers should report that affected variables
>>   were only declared here instead of appropriately defined
>>   (despite of attempts for scope-based resource management)?
>>
>
> We disabled GCC's check for uninitialized variables a long time ago
> because it had too many false positives.

Can further case distinctions (and compilation parameters) become more helpful
according to the discussed handling of the attribute “__cleanup” (or “__free”)?


>> * Did you extend detection support in the source code analysis tool “Smatch”
>>   for a questionable implementation detail?
>
> Yes.  Smatch detects this as an uninitialized variable.

Does the corresponding warning indicate requirements for scope-based resource management?

Regards,
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-24 13:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <0efe132b-b343-4438-bb00-5a4b82722ed3@moroto.mountain>
2024-03-23 16:56 ` [PATCH v2 net] ice: Fix freeing uninitialized pointers Markus Elfring
2024-03-24 10:43   ` Dan Carpenter
2024-03-24 13:22     ` [v2] " Markus Elfring

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 read-only IMAP folder(s) and NNTP newsgroup(s).