Commit 9ab230f8 authored by Allan Stephens's avatar Allan Stephens Committed by David S. Miller

[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: default avatarAllan Stephens <allan.stephens@windriver.com>
Signed-off-by: default avatarPer Liden <per.liden@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5e3c8854
...@@ -284,18 +284,18 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, ...@@ -284,18 +284,18 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
/* Ensure there is space for new sub-sequence */ /* Ensure there is space for new sub-sequence */
if (nseq->first_free == nseq->alloc) { if (nseq->first_free == nseq->alloc) {
struct sub_seq *sseqs = nseq->sseqs; struct sub_seq *sseqs = tipc_subseq_alloc(nseq->alloc * 2);
nseq->sseqs = tipc_subseq_alloc(nseq->alloc * 2);
if (nseq->sseqs != NULL) { if (!sseqs) {
memcpy(nseq->sseqs, sseqs,
nseq->alloc * sizeof (struct sub_seq));
kfree(sseqs);
dbg("Allocated %u sseqs\n", nseq->alloc);
nseq->alloc *= 2;
} else {
warn("Memory squeeze; failed to create sub-sequence\n"); warn("Memory squeeze; failed to create sub-sequence\n");
return NULL; 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); dbg("Have %u sseqs for type %u\n", nseq->alloc, type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment