Skip to contentSkip to conversation

ocfs2: free 'dummy_sc' in sc_fop_release() in case of memory leak

PATCH Applied piaojun 2 participants 2 messages Jun 25, 2017 – Jun 26, 2017 OCFS2

lore
Share & tools
lore

piaojun

author
#0 lore raw

PATCH 1/1 ocfs2: free 'dummy_sc' in sc_fop_release() in case of memory leak

'sd->dbg_sock' is malloc in sc_common_open(), but not freed at the end of sc_fop_release().

---
 fs/ocfs2/cluster/netdebug.c | 1 +
 1 file changed, 1 insertion(+)
fs/ocfs2/cluster/netdebug.c +1 -0
index 564c504..74a21f6 100644
@@ -426,6 +426,7 @@ static int sc_fop_release(struct inode *inode, struct file *file)
 	struct o2net_sock_container *dummy_sc = sd->dbg_sock;
 
 	o2net_debug_del_sc(dummy_sc);
+	kfree(dummy_sc);
 	return seq_release_private(inode, file);
 }
 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · piaojun

'sd->dbg_sock' is malloc in sc_common_open(), but not freed at the end of sc_fop_release().

Looks good.

Thanks,
Joseph

Quoted 16 lines
---
 fs/ocfs2/cluster/netdebug.c | 1 +
 1 file changed, 1 insertion(+)
fs/ocfs2/cluster/netdebug.c +1 -0
index 564c504..74a21f6 100644
@@ -426,6 +426,7 @@ static int sc_fop_release(struct inode *inode, struct file *file)
 	struct o2net_sock_container *dummy_sc = sd->dbg_sock;
 
 	o2net_debug_del_sc(dummy_sc);
+	kfree(dummy_sc);
 	return seq_release_private(inode, file);
 }