* [PATCH 0/2] Handle address parsing errors in export_find()
@ 2010-04-15 15:25 Chuck Lever
[not found] ` <20100415152401.4716.83632.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2010-04-15 15:25 UTC (permalink / raw)
To: steved; +Cc: linux-nfs
Steve-
Two more short subjects in the mountd IPv6 series.
---
Chuck Lever (2):
libexport.a: export_find() should handle address parsing errors
libexport.a: Add export_free()
support/export/export.c | 31 +++++++++++++++++++++----------
1 files changed, 21 insertions(+), 10 deletions(-)
--
Chuck Lever
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] libexport.a: Add export_free()
[not found] ` <20100415152401.4716.83632.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2010-04-15 15:25 ` Chuck Lever
2010-04-15 15:25 ` [PATCH 2/2] libexport.a: export_find() should handle address parsing errors Chuck Lever
2010-04-16 17:05 ` [PATCH 0/2] Handle address parsing errors in export_find() Steve Dickson
2 siblings, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2010-04-15 15:25 UTC (permalink / raw)
To: steved; +Cc: linux-nfs
Clean up: Introduce a helper to free an nfs_export record.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
support/export/export.c | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/support/export/export.c b/support/export/export.c
index 42e78f6..ddc8a84 100644
--- a/support/export/export.c
+++ b/support/export/export.c
@@ -28,6 +28,18 @@ static int export_check(nfs_export *, struct hostent *, char *);
static nfs_export *
export_allowed_internal(struct hostent *hp, char *path);
+static void
+export_free(nfs_export *exp)
+{
+ xfree(exp->m_export.e_squids);
+ xfree(exp->m_export.e_sqgids);
+ free(exp->m_export.e_mountpoint);
+ free(exp->m_export.e_fslocdata);
+
+ xfree(exp->m_export.e_hostname);
+ xfree(exp);
+}
+
static void warn_duplicated_exports(nfs_export *exp, struct exportent *eep)
{
if (exp->m_export.e_flags != eep->e_flags) {
@@ -260,6 +272,10 @@ export_check(nfs_export *exp, struct hostent *hp, char *path)
return client_check(exp->m_client, hp);
}
+/**
+ * export_freeall - deallocate all nfs_export records
+ *
+ */
void
export_freeall(void)
{
@@ -270,16 +286,7 @@ export_freeall(void)
for (exp = exportlist[i].p_head; exp; exp = nxt) {
nxt = exp->m_next;
client_release(exp->m_client);
- if (exp->m_export.e_squids)
- xfree(exp->m_export.e_squids);
- if (exp->m_export.e_sqgids)
- xfree(exp->m_export.e_sqgids);
- if (exp->m_export.e_mountpoint)
- free(exp->m_export.e_mountpoint);
- if (exp->m_export.e_fslocdata)
- free(exp->m_export.e_fslocdata);
- xfree(exp->m_export.e_hostname);
- xfree(exp);
+ export_free(exp);
}
for (j = 0; j < HASH_TABLE_SIZE; j++) {
exportlist[i].entries[j].p_first = NULL;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] libexport.a: export_find() should handle address parsing errors
[not found] ` <20100415152401.4716.83632.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-04-15 15:25 ` [PATCH 1/2] libexport.a: Add export_free() Chuck Lever
@ 2010-04-15 15:25 ` Chuck Lever
2010-04-16 17:05 ` [PATCH 0/2] Handle address parsing errors in export_find() Steve Dickson
2 siblings, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2010-04-15 15:25 UTC (permalink / raw)
To: steved; +Cc: linux-nfs
An address mask parsing error can cause client_init(), and therefore
client_dup(), to make our process exit suddenly. Soon we want to add
more complex address parsing in client_init(), so we need this
interface to be a little more robust.
Since export_find() can return NULL in some cases, it can handle NULL
returns from its subroutines if an address parsing error occurs, or if
memory is exhausted. Allow for client_dup() to return NULL instead of
exiting sideways.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
support/export/export.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/support/export/export.c b/support/export/export.c
index ddc8a84..3e4da69 100644
--- a/support/export/export.c
+++ b/support/export/export.c
@@ -129,6 +129,10 @@ export_dup(nfs_export *exp, struct hostent *hp)
if (exp->m_export.e_hostname)
new->m_export.e_hostname = xstrdup(exp->m_export.e_hostname);
clp = client_dup(exp->m_client, hp);
+ if (clp == NULL) {
+ export_free(new);
+ return NULL;
+ }
clp->m_count++;
new->m_client = clp;
new->m_mayexport = exp->m_mayexport;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Handle address parsing errors in export_find()
[not found] ` <20100415152401.4716.83632.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-04-15 15:25 ` [PATCH 1/2] libexport.a: Add export_free() Chuck Lever
2010-04-15 15:25 ` [PATCH 2/2] libexport.a: export_find() should handle address parsing errors Chuck Lever
@ 2010-04-16 17:05 ` Steve Dickson
2 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2010-04-16 17:05 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs
On 04/15/2010 11:25 AM, Chuck Lever wrote:
> Steve-
>
> Two more short subjects in the mountd IPv6 series.
>
> ---
>
> Chuck Lever (2):
> libexport.a: export_find() should handle address parsing errors
> libexport.a: Add export_free()
Committed and pushed!
steved.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-04-16 17:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-15 15:25 [PATCH 0/2] Handle address parsing errors in export_find() Chuck Lever
[not found] ` <20100415152401.4716.83632.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-04-15 15:25 ` [PATCH 1/2] libexport.a: Add export_free() Chuck Lever
2010-04-15 15:25 ` [PATCH 2/2] libexport.a: export_find() should handle address parsing errors Chuck Lever
2010-04-16 17:05 ` [PATCH 0/2] Handle address parsing errors in export_find() Steve Dickson
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.