Thread (118 messages) 118 messages, 8 authors, 2021-01-18

Re: [PATCH 5.10 086/103] regmap: debugfs: Fix a memory leak when calling regmap_attach_dev

From: Pavel Machek <hidden>
Date: 2021-01-15 20:27:39
Also in: lkml

Hi!
quoted
From: Xiaolei Wang <redacted>

commit cffa4b2122f5f3e53cf3d529bbc74651f95856d5 upstream.

After initializing the regmap through
syscon_regmap_lookup_by_compatible, then regmap_attach_dev to the
device, because the debugfs_name has been allocated, there is no
need to redistribute it again
? redistribute?

Anyway, this patch is clearly buggy:
quoted
 
 	if (!strcmp(name, "dummy")) {
-		kfree(map->debugfs_name);
+		if (!map->debugfs_name)
+			kfree(map->debugfs_name);
 
It runs kfree only if the variable is NULL. That's clearly useless,
kfree(NULL) is NOP, and this causes memory leak.
103/ of the series fixes this up. Sorry for the noise... 

Best regards,
								Pavel
-- 
http://www.livejournal.com/~pavelmachek

Attachments

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