Skip to contentSkip to conversation

batman-adv: Fix the wrong definition

PATCH NAK Yajun Deng 3 participants 4 messages Oct 28, 2021

Subsystems (3)
lore
Share & tools
lore

Yajun Deng

author
#0 lore raw

PATCH 1/1 batman-adv: Fix the wrong definition

There are three variables that are required at most, no need to define four variables.

Fixes 0fa4c30d710d ("batman-adv: Make sysfs support optional")
---
 net/batman-adv/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/main.c +1 -1
index 3ddd66e4c29e..758035b3796d 100644
@@ -656,7 +656,7 @@ int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type,
 {
 	int ret = -ENOMEM;
 	struct kobject *bat_kobj;
-	char *uevent_env[4] = { NULL, NULL, NULL, NULL };
+	char *uevent_env[3] = {};
 
 	bat_kobj = &bat_priv->soft_iface->dev.kobj;
 
Signature · 1 line
2.32.0
maintainer
#1 lore raw
Quoted 2 lines · On Thursday, 28 October 2021 09:23:06 CEST Yajun Deng wrote:

There are three variables that are required at most, no need to define four variables.

NAck. This is absolutely wrong - the last one is the "STOP" info. With your patch, it would sometimes (action != BATADV_UEV_DEL) not have the stop NULL. See also the second parameter in this for loop on line
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/kobject_uevent.c?id=1fc596a56b334f4d593a2b49e5ff55af6aaa0816#n548

We can discuss that this can be written in a better way. See
https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/1403982781.9064.33.camel@joe-AO725/
(also the remark from Antonio).

Quoted 2 lines
Fixes 0fa4c30d710d ("batman-adv: Make sysfs support optional")

Even this Fixes would be wrong. The code is there since commit c6bda689c2c9 ("batman-adv: add wrapper function to throw uevent in userspace").

But even then, this would not fix anything but just be a cleanup.

Quoted 19 lines
---
 net/batman-adv/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/main.c +1 -1
index 3ddd66e4c29e..758035b3796d 100644
@@ -656,7 +656,7 @@ int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type,
 {
 	int ret = -ENOMEM;
 	struct kobject *bat_kobj;
-	char *uevent_env[4] = { NULL, NULL, NULL, NULL };
+	char *uevent_env[3] = {};
 
 	bat_kobj = &bat_priv->soft_iface->dev.kobj;
 
#2 lore raw
In reply to Yajun Deng

Hi,

Quoted 5 lines · Yajun Deng

There are three variables that are required at most, no need to define four variables.

Fixes 0fa4c30d710d ("batman-adv: Make sysfs support optional")

NAK.

kobject_uevent_env() does not know how many items are stored in the array and thus requires it to be NULL terminated.

Please check the following for reference:

https://elixir.bootlin.com/linux/v5.15-rc6/source/lib/kobject_uevent.c#L548

OTOH I guess we could still use '{}' for the initialization.

Regards,

Signature · 1 line
Antonio Quartulli
#3 lore raw

October 28, 2021 3:35 PM, "Antonio Quartulli" <[email protected]> 写到:

Quoted 10 lines

Hi,

Quoted 5 lines · Yajun Deng

There are three variables that are required at most, no need to define four variables.

Fixes 0fa4c30d710d ("batman-adv: Make sysfs support optional")
Quoted 9 lines

NAK.

kobject_uevent_env() does not know how many items are stored in the array and thus requires it to be NULL terminated.

Please check the following for reference:

https://elixir.bootlin.com/linux/v5.15-rc6/source/lib/kobject_uevent.c#L548

Oh, I didn't notice there.

Quoted 6 lines

OTOH I guess we could still use '{}' for the initialization.

Regards,

--
Antonio Quartulli