Skip to contentSkip to conversation

sunrpc/cache: fix module refcnt leak in a failure path

PATCH Applied [email protected] 2 participants 2 messages Mar 11, 2010 – Mar 24, 2010 1 message not in the archive

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

PATCH 2/2 sunrpc/cache: fix module refcnt leak in a failure path

From: Li Zefan <[email protected]>

Don't forget to release the module refcnt if seq_open() returns failure.

Cc J. Bruce Fields <[email protected]>
Cc Neil Brown <[email protected]>
Cc Trond Myklebust <[email protected]>

---

 net/sunrpc/cache.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/sunrpc/cache.c renamed from net/sunrpc/cache.c~sunrpc-cache-fix-module-refcnt-leak-in-a-failure-path +3 -1
diff -puN net/sunrpc/cache.c~sunrpc-cache-fix-module-refcnt-leak-in-a-failure-path net/sunrpc/cache.c
@@ -1233,8 +1233,10 @@ static int content_open(struct inode *in
 	if (!cd || !try_module_get(cd->owner))
 		return -EACCES;
 	han = __seq_open_private(file, &cache_content_op, sizeof(*han));
-	if (han == NULL)
+	if (han == NULL) {
+		module_put(cd->owner);
 		return -ENOMEM;
+	}
 
 	han->cd = cd;
 	return 0;

_

A message that is not in the archive (sent off-list or not yet received): 201003112208.o2BM8Bng013520-AB4EexQrvXRQetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org

#2 lore raw
Quoted 3 lines · On Thu, Mar 11, 2010 at 02:08:10PM -0800, [email protected] wrote:

From: Li Zefan <[email protected]>

Don't forget to release the module refcnt if seq_open() returns failure.

Thanks, applied for 2.6.35.--b.

Quoted 27 lines
Cc J. Bruce Fields <[email protected]>
Cc Neil Brown <[email protected]>
Cc Trond Myklebust <[email protected]>

---

 net/sunrpc/cache.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff -puN net/sunrpc/cache.c~sunrpc-cache-fix-module-refcnt-leak-in-a-failure-path net/sunrpc/cache.c

net/sunrpc/cache.c renamed from net/sunrpc/cache.c~sunrpc-cache-fix-module-refcnt-leak-in-a-failure-path +3 -1
@@ -1233,8 +1233,10 @@ static int content_open(struct inode *in
 	if (!cd || !try_module_get(cd->owner))
 		return -EACCES;
 	han = __seq_open_private(file, &cache_content_op, sizeof(*han));
-	if (han == NULL)
+	if (han == NULL) {
+		module_put(cd->owner);
 		return -ENOMEM;
+	}
 
 	han->cd = cd;
 	return 0;

_