summaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2006-06-26 08:37:24 +0200
committerDavid S. Miller <davem@davemloft.net>2006-06-26 08:37:24 +0200
commit9ab230f82f404e534387dda6067072291441a34d (patch)
treec0f6b2a17d640bea336795988f109e53120c0711 /net/tipc
parent[TIPC] Improved tolerance to promiscuous mode interface (diff)
downloadlinux-9ab230f82f404e534387dda6067072291441a34d.tar.xz
linux-9ab230f82f404e534387dda6067072291441a34d.zip
[TIPC]: Prevent name table corruption if no room for new publication
Now exits cleanly if attempt to allocate larger array of subsequences fails, without losing track of pointer to existing array. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Per Liden <per.liden@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/name_table.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index d129422fc5c2..051143648edb 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -284,18 +284,18 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
/* Ensure there is space for new sub-sequence */
if (nseq->first_free == nseq->alloc) {
- struct sub_seq *sseqs = nseq->sseqs;
- nseq->sseqs = tipc_subseq_alloc(nseq->alloc * 2);
- if (nseq->sseqs != NULL) {
- memcpy(nseq->sseqs, sseqs,
- nseq->alloc * sizeof (struct sub_seq));
- kfree(sseqs);
- dbg("Allocated %u sseqs\n", nseq->alloc);
- nseq->alloc *= 2;
- } else {
+ struct sub_seq *sseqs = tipc_subseq_alloc(nseq->alloc * 2);
+
+ if (!sseqs) {
warn("Memory squeeze; failed to create sub-sequence\n");
return NULL;
}
+ dbg("Allocated %u more sseqs\n", nseq->alloc);
+ memcpy(sseqs, nseq->sseqs,
+ nseq->alloc * sizeof(struct sub_seq));
+ kfree(nseq->sseqs);
+ nseq->sseqs = sseqs;
+ nseq->alloc *= 2;
}
dbg("Have %u sseqs for type %u\n", nseq->alloc, type);