Skip to content

Commit f191d5a

Browse files
committed
Clean up format data after a failed probe
Make sure that format-specific data is cleaned up after a failed probe. Since private data may not be even allocated at that point, the cleanup handlers must check that the pointer is not NULL before dereferencing it. Add this check to devmem and lkcd cleanup handlers. Signed-off-by: Petr Tesarik <[email protected]>
1 parent 24e53ed commit f191d5a

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/kdumpfile/devmem.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ devmem_cleanup(struct kdump_shared *shared)
339339
{
340340
struct devmem_priv *dmp = shared->fmtdata;
341341

342+
if (!dmp)
343+
return;
344+
342345
if (dmp->ce) {
343346
free(dmp->ce[0].data);
344347
free(dmp->ce);

src/kdumpfile/lkcd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,9 @@ lkcd_cleanup(struct kdump_shared *shared)
10701070
{
10711071
struct lkcd_priv *lkcdp = shared->fmtdata;
10721072

1073+
if (!lkcdp)
1074+
return;
1075+
10731076
free_level1(lkcdp->pfn_level1, lkcdp->l1_size);
10741077
mutex_destroy(&lkcdp->pfn_block_mutex);
10751078
if (lkcdp->cbuf_slot >= 0)

src/kdumpfile/open.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ open_dump(kdump_ctx_t *ctx)
338338
ret = ctx->shared->ops->probe(ctx);
339339
if (ret == KDUMP_OK)
340340
return finish_open_dump(ctx);
341+
if (ctx->shared->ops->cleanup)
342+
ctx->shared->ops->cleanup(ctx->shared);
341343
if (ret != KDUMP_NOPROBE)
342344
return ret;
343345

0 commit comments

Comments
 (0)