[PATCH 2/3] kobject: Improve a size determination in kobject_uevent_env()

Markus Elfring posted 3 patches 1 year, 12 months ago
[PATCH 2/3] kobject: Improve a size determination in kobject_uevent_env()
Posted by Markus Elfring 1 year, 12 months ago
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 19 Dec 2023 16:00:22 +0100

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 lib/kobject_uevent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 811e579ed89d..a9b1bc02f65c 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -521,7 +521,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
 	}

 	/* environment buffer */
-	env = kzalloc(sizeof(struct kobj_uevent_env), GFP_KERNEL);
+	env = kzalloc(sizeof(*env), GFP_KERNEL);
 	if (!env)
 		return -ENOMEM;

--
2.43.0
Re: [PATCH 2/3] kobject: Improve a size determination in kobject_uevent_env()
Posted by Greg Kroah-Hartman 1 year, 12 months ago
On Tue, Dec 19, 2023 at 04:34:19PM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 19 Dec 2023 16:00:22 +0100
> 
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Sorry, but for obvious reasons, I'm still not taking patches from you.

best of luck,

greg k-h