* [PATCH] Don't test for NULL firmware before releasing
@ 2023-02-16 1:37 Jesper Juhl
2023-02-16 13:19 ` Stanislaw Gruszka
0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2023-02-16 1:37 UTC (permalink / raw)
To: linux-kernel
Cc: linux-tegra, dri-devel, Jonathan Hunter, Daniel Vetter,
David Airlie, Thierry Reding
From 4fe34831e2e7677b1c9616356f0a2e0a36ec092f Mon Sep 17 00:00:00 2001
From: Jesper Juhl <jesperjuhl76@gmail.com>
Date: Thu, 16 Feb 2023 02:33:05 +0100
Subject: [PATCH] Don't test for NULL firmware before releasing
release_firmware() tests for a NULL pointer itself, no need to do it up-front.
Signed-off-by: Jesper Juhl <jesperjuhl76@gmail.com>
---
drivers/gpu/drm/tegra/falcon.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/tegra/falcon.c b/drivers/gpu/drm/tegra/falcon.c
index c0d85463eb1a..ae599441f031 100644
--- a/drivers/gpu/drm/tegra/falcon.c
+++ b/drivers/gpu/drm/tegra/falcon.c
@@ -153,8 +153,7 @@ int falcon_init(struct falcon *falcon)
void falcon_exit(struct falcon *falcon)
{
- if (falcon->firmware.firmware)
- release_firmware(falcon->firmware.firmware);
+ release_firmware(falcon->firmware.firmware);
}
int falcon_boot(struct falcon *falcon)
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Don't test for NULL firmware before releasing
2023-02-16 1:37 [PATCH] Don't test for NULL firmware before releasing Jesper Juhl
@ 2023-02-16 13:19 ` Stanislaw Gruszka
2023-02-17 12:04 ` Mikko Perttunen
0 siblings, 1 reply; 3+ messages in thread
From: Stanislaw Gruszka @ 2023-02-16 13:19 UTC (permalink / raw)
To: Jesper Juhl
Cc: linux-kernel, dri-devel, Jonathan Hunter, Thierry Reding, linux-tegra
Hi
On Thu, Feb 16, 2023 at 02:37:15AM +0100, Jesper Juhl wrote:
> From 4fe34831e2e7677b1c9616356f0a2e0a36ec092f Mon Sep 17 00:00:00 2001
> From: Jesper Juhl <jesperjuhl76@gmail.com>
> Date: Thu, 16 Feb 2023 02:33:05 +0100
> Subject: [PATCH] Don't test for NULL firmware before releasing
>
> release_firmware() tests for a NULL pointer itself, no need to do it up-front.
>
> Signed-off-by: Jesper Juhl <jesperjuhl76@gmail.com>
>
> ---
> drivers/gpu/drm/tegra/falcon.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/tegra/falcon.c b/drivers/gpu/drm/tegra/falcon.c
> index c0d85463eb1a..ae599441f031 100644
> --- a/drivers/gpu/drm/tegra/falcon.c
> +++ b/drivers/gpu/drm/tegra/falcon.c
> @@ -153,8 +153,7 @@ int falcon_init(struct falcon *falcon)
>
> void falcon_exit(struct falcon *falcon)
> {
> - if (falcon->firmware.firmware)
> - release_firmware(falcon->firmware.firmware);
> + release_firmware(falcon->firmware.firmware);
Please check patches with checkpatch.pl before posting.
Regards
Stanislaw
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Don't test for NULL firmware before releasing
2023-02-16 13:19 ` Stanislaw Gruszka
@ 2023-02-17 12:04 ` Mikko Perttunen
0 siblings, 0 replies; 3+ messages in thread
From: Mikko Perttunen @ 2023-02-17 12:04 UTC (permalink / raw)
To: Stanislaw Gruszka, Jesper Juhl
Cc: linux-kernel, dri-devel, Jonathan Hunter, Thierry Reding, linux-tegra
On 2/16/23 15:19, Stanislaw Gruszka wrote:
> Hi
>
> On Thu, Feb 16, 2023 at 02:37:15AM +0100, Jesper Juhl wrote:
>> From 4fe34831e2e7677b1c9616356f0a2e0a36ec092f Mon Sep 17 00:00:00 2001
>> From: Jesper Juhl <jesperjuhl76@gmail.com>
>> Date: Thu, 16 Feb 2023 02:33:05 +0100
>> Subject: [PATCH] Don't test for NULL firmware before releasing
>>
>> release_firmware() tests for a NULL pointer itself, no need to do it up-front.
>>
>> Signed-off-by: Jesper Juhl <jesperjuhl76@gmail.com>
>>
>> ---
>> drivers/gpu/drm/tegra/falcon.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/tegra/falcon.c b/drivers/gpu/drm/tegra/falcon.c
>> index c0d85463eb1a..ae599441f031 100644
>> --- a/drivers/gpu/drm/tegra/falcon.c
>> +++ b/drivers/gpu/drm/tegra/falcon.c
>> @@ -153,8 +153,7 @@ int falcon_init(struct falcon *falcon)
>>
>> void falcon_exit(struct falcon *falcon)
>> {
>> - if (falcon->firmware.firmware)
>> - release_firmware(falcon->firmware.firmware);
>> + release_firmware(falcon->firmware.firmware);
>
> Please check patches with checkpatch.pl before posting.
>
> Regards
> Stanislaw
>
Aside the formatting deficiencies, I'm also not in favor of relying on
NULL checks inside callees since doing so removes contextual information
from the programmer; just looking at the code, it is easy to assume the
pointer cannot be NULL if there is no NULL check. Recently had a longer
thread about this in the context of kfree in TegraDRM.
Thanks
Mikko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-17 12:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16 1:37 [PATCH] Don't test for NULL firmware before releasing Jesper Juhl
2023-02-16 13:19 ` Stanislaw Gruszka
2023-02-17 12:04 ` Mikko Perttunen
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).