* [PATCH] driver core: faux: Move a variable assignment behind a condition check in faux_device_destroy()
@ 2026-07-12 13:56 Markus Elfring
2026-07-12 14:09 ` Greg Kroah-Hartman
0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2026-07-12 13:56 UTC (permalink / raw)
To: driver-core, Danilo Krummrich, Greg Kroah-Hartman,
Jonathan Cameron, Lyude Paul, Rafael J. Wysocki,
Thomas Weißschuh, Zijun Hu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 12 Jul 2026 15:45:19 +0200
The address of a data structure member was determined before
a corresponding null pointer check in the implementation of
the function “faux_device_destroy”.
Thus avoid the risk for undefined behaviour by moving the assignment
for the variable “dev” behind a condition check.
This issue was detected by using the Coccinelle software.
Fixes: 35fa2d88ca9481e5caf533d58b99ca259c63b2fe ("driver core: add a faux bus for use when a simple device/bus is needed")
Cc: stable@vger.kernel.org
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/base/faux.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/base/faux.c b/drivers/base/faux.c
index a8329f88222e..4eb22d082552 100644
--- a/drivers/base/faux.c
+++ b/drivers/base/faux.c
@@ -221,11 +221,12 @@ EXPORT_SYMBOL_GPL(faux_device_create);
*/
void faux_device_destroy(struct faux_device *faux_dev)
{
- struct device *dev = &faux_dev->dev;
+ struct device *dev;
if (!faux_dev)
return;
+ dev = &faux_dev->dev;
device_del(dev);
/* The final put_device() will clean up the memory we allocated for this device. */
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] driver core: faux: Move a variable assignment behind a condition check in faux_device_destroy()
2026-07-12 13:56 [PATCH] driver core: faux: Move a variable assignment behind a condition check in faux_device_destroy() Markus Elfring
@ 2026-07-12 14:09 ` Greg Kroah-Hartman
2026-07-12 16:23 ` Markus Elfring
0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2026-07-12 14:09 UTC (permalink / raw)
To: Markus Elfring
Cc: driver-core, Danilo Krummrich, Jonathan Cameron, Lyude Paul,
Rafael J. Wysocki, Thomas Weißschuh, Zijun Hu, LKML,
kernel-janitors
On Sun, Jul 12, 2026 at 03:56:09PM +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 12 Jul 2026 15:45:19 +0200
>
> The address of a data structure member was determined before
> a corresponding null pointer check in the implementation of
> the function “faux_device_destroy”.
>
> Thus avoid the risk for undefined behaviour by moving the assignment
> for the variable “dev” behind a condition check.
There is no such "undefined behavior" here, sorry, please fix your
tools.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] driver core: faux: Move a variable assignment behind a condition check in faux_device_destroy()
2026-07-12 14:09 ` Greg Kroah-Hartman
@ 2026-07-12 16:23 ` Markus Elfring
2026-07-12 16:39 ` Greg Kroah-Hartman
0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2026-07-12 16:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, driver-core
Cc: Danilo Krummrich, Jonathan Cameron, Lyude Paul, Rafael J. Wysocki,
Thomas Weißschuh, Zijun Hu, LKML, kernel-janitors
>> The address of a data structure member was determined before
>> a corresponding null pointer check in the implementation of
>> the function “faux_device_destroy”.
>>
>> Thus avoid the risk for undefined behaviour by moving the assignment
>> for the variable “dev” behind a condition check.
>
> There is no such "undefined behavior" here, sorry, please fix your tools.
Please take another look at related information sources.
EXP34-C: Do not dereference null pointers
https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/expressions-exp/exp34-c/
See also:
https://lore.kernel.org/kernel-janitors/d7a8e34b-e490-47fc-b892-886e1c799c4f@web.de/
https://lkml.org/lkml/2026/7/2/2241
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] driver core: faux: Move a variable assignment behind a condition check in faux_device_destroy()
2026-07-12 16:23 ` Markus Elfring
@ 2026-07-12 16:39 ` Greg Kroah-Hartman
2026-07-12 16:54 ` Markus Elfring
0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2026-07-12 16:39 UTC (permalink / raw)
To: Markus Elfring
Cc: driver-core, Danilo Krummrich, Jonathan Cameron, Lyude Paul,
Rafael J. Wysocki, Thomas Weißschuh, Zijun Hu, LKML,
kernel-janitors
On Sun, Jul 12, 2026 at 06:23:47PM +0200, Markus Elfring wrote:
> >> The address of a data structure member was determined before
> >> a corresponding null pointer check in the implementation of
> >> the function “faux_device_destroy”.
> >>
> >> Thus avoid the risk for undefined behaviour by moving the assignment
> >> for the variable “dev” behind a condition check.
> >
> > There is no such "undefined behavior" here, sorry, please fix your tools.
>
> Please take another look at related information sources.
>
> EXP34-C: Do not dereference null pointers
> https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/expressions-exp/exp34-c/
>
>
> See also:
> https://lore.kernel.org/kernel-janitors/d7a8e34b-e490-47fc-b892-886e1c799c4f@web.de/
> https://lkml.org/lkml/2026/7/2/2241
Please see the places in the past where I have rejected this very patch.
Nothing has changed since then.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: driver core: faux: Move a variable assignment behind a condition check in faux_device_destroy()
2026-07-12 16:39 ` Greg Kroah-Hartman
@ 2026-07-12 16:54 ` Markus Elfring
0 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2026-07-12 16:54 UTC (permalink / raw)
To: Greg Kroah-Hartman, driver-core
Cc: Danilo Krummrich, Jonathan Cameron, Lyude Paul, Rafael J. Wysocki,
Thomas Weißschuh, Zijun Hu, LKML, kernel-janitors
…
>> Please take another look at related information sources.
>>
>> EXP34-C: Do not dereference null pointers
>> https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/expressions-exp/exp34-c/
>>
>>
>> See also:
>> https://lore.kernel.org/kernel-janitors/d7a8e34b-e490-47fc-b892-886e1c799c4f@web.de/
>> https://lkml.org/lkml/2026/7/2/2241
>
> Please see the places in the past where I have rejected this very patch.
> Nothing has changed since then.
Can involved special development views be resolved better by applying scope-based resource management
for the affected function implementation?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-12 16:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-12 13:56 [PATCH] driver core: faux: Move a variable assignment behind a condition check in faux_device_destroy() Markus Elfring
2026-07-12 14:09 ` Greg Kroah-Hartman
2026-07-12 16:23 ` Markus Elfring
2026-07-12 16:39 ` Greg Kroah-Hartman
2026-07-12 16:54 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox