Skip to contentSkip to conversation

soc: fix comment for freeing soc_dev_attr

PATCH In review Krzysztof Kozlowski 2 participants 2 messages Dec 7, 2020 – Dec 8, 2020 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: fix comment for freeing soc_dev_attr

The soc_dev_attr is stored soc_dev->attr during soc_device_register() so it could be used till the cleanup call: soc_device_unregister(). Therefore this memory should not be freed prior, but after unregistering soc device.

---
 drivers/base/soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/soc.c +1 -1
index d34609bb7386..0af5363a582c 100644
@@ -168,7 +168,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr
 }
 EXPORT_SYMBOL_GPL(soc_device_register);
 
-/* Ensure soc_dev->attr is freed prior to calling soc_device_unregister. */
+/* Ensure soc_dev->attr is freed after calling soc_device_unregister. */
 void soc_device_unregister(struct soc_device *soc_dev)
 {
 	device_unregister(&soc_dev->dev);
Signature · 1 line
2.25.1
#1 lore raw

Hi Krzysztof,

Quoted 6 lines · Krzysztof Kozlowski

The soc_dev_attr is stored soc_dev->attr during soc_device_register() so it could be used till the cleanup call: soc_device_unregister(). Therefore this memory should not be freed prior, but after unregistering soc device.

Thanks for your patch!

drivers/base/soc.c struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr · line 171

Quoted 8 lines
drivers/base/soc.c +1 -1
@@ -168,7 +168,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr
 }
 EXPORT_SYMBOL_GPL(soc_device_register);
 
-/* Ensure soc_dev->attr is freed prior to calling soc_device_unregister. */
+/* Ensure soc_dev->attr is freed after calling soc_device_unregister. */

"Ensure" makes it sound like the freeing is taken care of, which is not, as it should be handled by the caller.

What about "soc_dev->attr should be freed after calling soc_device_unregister."?

drivers/base/soc.c struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr · line 174

Quoted 3 lines
drivers/base/soc.c +0 -0
 void soc_device_unregister(struct soc_device *soc_dev)
 {
        device_unregister(&soc_dev->dev);

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds