* [cocci] [PATCH 0/3] kobject: Adjustments for kobject_uevent_env()
@ 2023-12-19 15:30 Markus Elfring
2023-12-19 15:32 ` [cocci] [PATCH 1/3] kobject: Add a jump label in kobject_uevent_env() Markus Elfring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Markus Elfring @ 2023-12-19 15:30 UTC (permalink / raw)
To: kernel-janitors, Andrew Morton, Greg Kroah-Hartman, Rafael J. Wysocki
Cc: LKML, cocci
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 19 Dec 2023 16:22:33 +0100
A few update suggestions were taken into account
from source code analysis.
Markus Elfring (3):
Add a jump label
Improve a size determination
Delete an unnecessary variable initialisation
lib/kobject_uevent.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [cocci] [PATCH 1/3] kobject: Add a jump label in kobject_uevent_env()
2023-12-19 15:30 [cocci] [PATCH 0/3] kobject: Adjustments for kobject_uevent_env() Markus Elfring
@ 2023-12-19 15:32 ` Markus Elfring
2023-12-19 15:34 ` [cocci] [PATCH 2/3] kobject: Improve a size determination " Markus Elfring
2023-12-19 15:36 ` [cocci] [PATCH 3/3] kobject: Delete an unnecessary variable initialisation " Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2023-12-19 15:32 UTC (permalink / raw)
To: kernel-janitors, Andrew Morton, Greg Kroah-Hartman, Rafael J. Wysocki
Cc: LKML, cocci
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 19 Dec 2023 14:16:35 +0100
Use another label so that a call of the function “kfree” can be avoided
after a failed call of the function “kobject_get_path”.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
lib/kobject_uevent.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index fb9a2f06dd1e..811e579ed89d 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -529,7 +529,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
devpath = kobject_get_path(kobj, GFP_KERNEL);
if (!devpath) {
retval = -ENOENT;
- goto exit;
+ goto free_env;
}
/* default keys */
@@ -623,6 +623,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
exit:
kfree(devpath);
+free_env:
kfree(env);
return retval;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [cocci] [PATCH 2/3] kobject: Improve a size determination in kobject_uevent_env()
2023-12-19 15:30 [cocci] [PATCH 0/3] kobject: Adjustments for kobject_uevent_env() Markus Elfring
2023-12-19 15:32 ` [cocci] [PATCH 1/3] kobject: Add a jump label in kobject_uevent_env() Markus Elfring
@ 2023-12-19 15:34 ` Markus Elfring
2023-12-19 15:36 ` [cocci] [PATCH 3/3] kobject: Delete an unnecessary variable initialisation " Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2023-12-19 15:34 UTC (permalink / raw)
To: kernel-janitors, Andrew Morton, Greg Kroah-Hartman, Rafael J. Wysocki
Cc: LKML, cocci
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [cocci] [PATCH 3/3] kobject: Delete an unnecessary variable initialisation in kobject_uevent_env()
2023-12-19 15:30 [cocci] [PATCH 0/3] kobject: Adjustments for kobject_uevent_env() Markus Elfring
2023-12-19 15:32 ` [cocci] [PATCH 1/3] kobject: Add a jump label in kobject_uevent_env() Markus Elfring
2023-12-19 15:34 ` [cocci] [PATCH 2/3] kobject: Improve a size determination " Markus Elfring
@ 2023-12-19 15:36 ` Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2023-12-19 15:36 UTC (permalink / raw)
To: kernel-janitors, Andrew Morton, Greg Kroah-Hartman, Rafael J. Wysocki
Cc: LKML, cocci
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 19 Dec 2023 16:03:39 +0100
The local variable “devpath” will eventually be set to an appropriate
pointer a bit later.
Thus omit the explicit initialisation at the beginning.
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 a9b1bc02f65c..1b7b42dc160c 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -459,7 +459,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
{
struct kobj_uevent_env *env;
const char *action_string = kobject_actions[action];
- const char *devpath = NULL;
+ const char *devpath;
const char *subsystem;
struct kobject *top_kobj;
struct kset *kset;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-12-19 15:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-19 15:30 [cocci] [PATCH 0/3] kobject: Adjustments for kobject_uevent_env() Markus Elfring
2023-12-19 15:32 ` [cocci] [PATCH 1/3] kobject: Add a jump label in kobject_uevent_env() Markus Elfring
2023-12-19 15:34 ` [cocci] [PATCH 2/3] kobject: Improve a size determination " Markus Elfring
2023-12-19 15:36 ` [cocci] [PATCH 3/3] kobject: Delete an unnecessary variable initialisation " 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 NNTP newsgroup(s).