Thread (5 messages) 5 messages, 2 authors, 2024-06-20

Re: [PATCH v2 1/2] mfd: syscon: add of_syscon_register_regmap() API

From: Peter Griffin <peter.griffin@linaro.org>
Date: 2024-06-20 11:53:53
Also in: linux-samsung-soc, lkml

Hi Arnd,

Thanks for the review feedback.

On Thu, 20 Jun 2024 at 12:40, Arnd Bergmann [off-list ref] wrote:

On Thu, Jun 20, 2024, at 13:24, Peter Griffin wrote:
quoted
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
---
Changes in v2:
- Keep syscon lock held between checking and adding entry (Krzysztof)
Unfortunately you now have a different bug:
quoted
+     /* check if syscon entry already exists */
+     spin_lock(&syscon_list_slock);
+
+     list_for_each_entry(entry, &syscon_list, list)
+             if (entry->np == np) {
+                     syscon = entry;
+                     break;
+             }
+
+     if (syscon) {
+             ret = -EEXIST;
+             goto err_unlock;
+     }
+
+     syscon = kzalloc(sizeof(*syscon), GFP_KERNEL);
+     if (!syscon) {
+             ret = -ENOMEM;
+             goto err_unlock;
+     }
You can't use GFP_KERNEL while holding a spinlock.

I think the correct way to do this is to move the allocation
before the locked section, and then free it in the failure case.
Thanks for spotting this! I'll update as you suggest in v3.

Peter.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help