All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Andrew Morton <akpm@osdl.org>
Cc: neilb@cse.unsw.edu.au, nfs@lists.sourceforge.net
Subject: [PATCH] kNFSd - 3 of 5 - ip_map_init does a kmalloc which isn't checked
Date: Sun, 8 Feb 2004 15:43:25 -0500	[thread overview]
Message-ID: <20040208204325.GD27482@fieldses.org> (raw)
In-Reply-To: <20040208203018.GA27482@fieldses.org>


There is no way to return an error from a cache init routine, so instead we
make sure to pre-allocate the memory needed, and free it after the lookup if
the lookup failed.


 net/sunrpc/svcauth_unix.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff -puN net/sunrpc/svcauth_unix.c~neil_NfsdIpMapInit net/sunrpc/svcauth_unix.c
--- linux-2.6.1/net/sunrpc/svcauth_unix.c~neil_NfsdIpMapInit	2004-02-08 01:50:33.000000000 -0500
+++ linux-2.6.1-bfields/net/sunrpc/svcauth_unix.c	2004-02-08 01:50:33.000000000 -0500
@@ -119,7 +119,8 @@ static inline int ip_map_match(struct ip
 }
 static inline void ip_map_init(struct ip_map *new, struct ip_map *item)
 {
-	new->m_class = strdup(item->m_class);
+	new->m_class = item->m_class;
+	item->m_class = NULL;
 	new->m_addr.s_addr = item->m_addr.s_addr;
 }
 static inline void ip_map_update(struct ip_map *new, struct ip_map *item)
@@ -191,7 +192,9 @@ static int ip_map_parse(struct cache_det
 	} else
 		dom = NULL;
 
-	ipm.m_class = class;
+	ipm.m_class = strdup(class);
+	if (ipm.m_class == NULL)
+		return -ENOMEM;
 	ipm.m_addr.s_addr =
 		htonl((((((b1<<8)|b2)<<8)|b3)<<8)|b4);
 	ipm.h.flags = 0;
@@ -207,6 +210,7 @@ static int ip_map_parse(struct cache_det
 		ip_map_put(&ipmp->h, &ip_map_cache);
 	if (dom)
 		auth_domain_put(dom);
+	if (ipm.m_class) kfree(ipm.m_class);
 	if (!ipmp)
 		return -ENOMEM;
 	cache_flush();
@@ -266,7 +270,9 @@ int auth_unix_add_addr(struct in_addr ad
 	if (dom->flavour != RPC_AUTH_UNIX)
 		return -EINVAL;
 	udom = container_of(dom, struct unix_domain, h);
-	ip.m_class = "nfsd";
+	ip.m_class = strdup("nfsd");
+	if (!ip.m_class)
+		return -ENOMEM;
 	ip.m_addr = addr;
 	ip.m_client = udom;
 	ip.m_add_change = udom->addr_changes+1;
@@ -274,6 +280,7 @@ int auth_unix_add_addr(struct in_addr ad
 	ip.h.expiry_time = NEVER;
 	
 	ipmp = ip_map_lookup(&ip, 1);
+	if (ip.m_class) kfree(ip.m_class);
 	if (ipmp) {
 		ip_map_put(&ipmp->h, &ip_map_cache);
 		return 0;

_


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

  parent reply	other threads:[~2004-02-08 20:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-06  5:13 [PATCH] kNFSd - 0 of 5 - Introduction NeilBrown
2004-02-06  5:13 ` [PATCH] kNFSd - 1 of 5 - Fix possible scheduling_while_atomic in cache.c NeilBrown
2004-02-06  5:13 ` [PATCH] kNFSd - 3 of 5 - Allow sunrpc/svc cache init function to modify the "key" NeilBrown
2004-02-07  9:30   ` Andrew Morton
2004-02-06  5:13 ` [PATCH] kNFSd - 2 of 5 - ip_map_init does a kmalloc which isn't checked NeilBrown
2004-02-07  9:24   ` Andrew Morton
2004-02-08  4:37     ` J. Bruce Fields
2004-02-08  5:46       ` Andrew Morton
2004-02-08  5:59         ` J. Bruce Fields
2004-02-08 20:30           ` J. Bruce Fields
2004-02-08 20:38             ` [PATCH] kNFSd - 1 of 5 - Fix possible scheduling_while_atomic in cache.c J. Bruce Fields
2004-02-08 20:41             ` [PATCH] kNFSd - 2 of 5 - Allow sunrpc/svc cache init function to modify the "key" J. Bruce Fields
2004-02-08 20:43             ` J. Bruce Fields [this message]
2004-02-08 20:46             ` [PATCH] kNFSd - 4 of 5 - convert NFS /proc interfaces to seq_file J. Bruce Fields
2004-02-08 20:48             ` [PATCH] kNFSd - 5 of 5 - fix build problems in nfs w/o proc_fs J. Bruce Fields
2004-02-09 17:32             ` Re: [PATCH] kNFSd - 2 of 5 - ip_map_init does a kmalloc which isn't checked Andrew Morton
2004-02-09 21:51               ` J. Bruce Fields
2004-02-09 22:10                 ` Andrew Morton
2004-02-06  5:13 ` [PATCH] kNFSd - 5 of 5 - fix build problems in nfs w/o proc_fs on 2.6.0-test5 NeilBrown
2004-02-06  5:13 ` [PATCH] kNFSd - 4 of 5 - convert NFS /proc interfaces to seq_file NeilBrown
2004-02-06  5:32 ` [PATCH] kNFSd - 0 of 5 - Introduction Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040208204325.GD27482@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=akpm@osdl.org \
    --cc=neilb@cse.unsw.edu.au \
    --cc=nfs@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.