Skip to contentSkip to conversation

cifs: fix module refcount leak in find_domain_name

PATCH In review Jeff Layton 1 participant 2 messages Sep 24, 2010 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 cifs: fix module refcount leak in find_domain_name

find_domain_name() uses load_nls_default which takes a module reference on the appropriate NLS module, but doesn't put it.

Cc Shirish Pargaonkar <[email protected]>
---
 fs/cifs/cifsencrypt.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
fs/cifs/cifsencrypt.c +4 -1
index 388ebe3..ccb13e6 100644
@@ -363,13 +363,16 @@ find_domain_name(struct cifsSesInfo *ses)
 			if (!attrsize)
 				break;
 			if (!ses->domainName) {
+				struct nls_table *default_nls;
 				ses->domainName =
 					kmalloc(attrsize + 1, GFP_KERNEL);
 				if (!ses->domainName)
 						return -ENOMEM;
+				default_nls = load_nls_default();
 				cifs_from_ucs2(ses->domainName,
 					(__le16 *)blobptr, attrsize, attrsize,
-					load_nls_default(), false);
+					default_nls, false);
+				unload_nls(default_nls);
 				break;
 			}
 		}
Signature · 1 line
1.7.2.3

A message that is not in the archive (sent off-list or not yet received): 1285333112-9040-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw
Quoted 21 lines · On Fri, 24 Sep 2010 08:58:32 -0400 Jeff Layton…

find_domain_name() uses load_nls_default which takes a module reference on the appropriate NLS module, but doesn't put it.

Cc Shirish Pargaonkar <[email protected]>
---
 fs/cifs/cifsencrypt.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
fs/cifs/cifsencrypt.c +1 -0
index 388ebe3..ccb13e6 100644
@@ -363,13 +363,16 @@ find_domain_name(struct cifsSesInfo *ses)
 			if (!attrsize)
 				break;
 			if (!ses->domainName) {
+				struct nls_table *default_nls;
 				ses->domainName =
 					kmalloc(attrsize + 1, GFP_KERNEL);
 				if (!ses->domainName)

fs/cifs/cifsencrypt.c find_domain_name(struct cifsSesInfo *ses) · line 378

Quoted 10 lines
fs/cifs/cifsencrypt.c +3 -1
 						return -ENOMEM;
+				default_nls = load_nls_default();
 				cifs_from_ucs2(ses->domainName,
 					(__le16 *)blobptr, attrsize, attrsize,
-					load_nls_default(), false);
+					default_nls, false);
+				unload_nls(default_nls);
 				break;
 			}
 		}

My apologies for the misleading subject prefix. This patch isn't part of a series. It's a standalone patch. There is no patch 1/2.

Signature · 1 line
Jeff Layton <[email protected]>