diff mbox series

[v2,05/16] reset: Avoid a warning in devm_reset_bulk_get_by_node()

Message ID 20210513193923.v2.5.Ia04371ac898c4f270ada6f27a9c013b0f8fc211b@changeid
State Accepted
Commit ca4c24509c60cfc95563d25b482cfed3789aca59
Delegated to: Tom Rini
Headers show
Series [v2,01/16] sandbox: net: Ensure host name is always a valid string | expand

Commit Message

Simon Glass May 14, 2021, 1:39 a.m. UTC
The devres_alloc() function is intended to avoid the need for freeing
memory, although in practice it may not be enabled, thus leading to a true
leak.

Nevertheless this is intended. Add a comment to explain this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Coverity (CID: 312952)
---

Changes in v2:
- Add a standard comment instead of a Coverity annotation

 drivers/reset/reset-uclass.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Tom Rini July 16, 2021, 3:51 p.m. UTC | #1
On Thu, May 13, 2021 at 07:39:21PM -0600, Simon Glass wrote:

> The devres_alloc() function is intended to avoid the need for freeing
> memory, although in practice it may not be enabled, thus leading to a true
> leak.
> 
> Nevertheless this is intended. Add a comment to explain this.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reported-by: Coverity (CID: 312952)

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index ac89eaf098a..a3a088d1b5c 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -323,6 +323,8 @@  struct reset_ctl_bulk *devm_reset_bulk_get_by_node(struct udevice *dev,
 	bulk = devres_alloc(devm_reset_bulk_release,
 			    sizeof(struct reset_ctl_bulk),
 			    __GFP_ZERO);
+
+	/* this looks like a leak, but devres takes care of it */
 	if (unlikely(!bulk))
 		return ERR_PTR(-ENOMEM);