[PATCH 9/9] mcheck: let mcheck_abortfunc_t print the pointer
Eugene Uriev
eugeneuriev at gmail.com
Sun Mar 31 22:03:27 CEST 2024
Signed-off-by: Eugene Uriev <eugeneuriev at gmail.com>
---
common/mcheck_core.inc.h | 16 ++++++++--------
include/mcheck.h | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/common/mcheck_core.inc.h b/common/mcheck_core.inc.h
index 2f11ac567f..6902140992 100644
--- a/common/mcheck_core.inc.h
+++ b/common/mcheck_core.inc.h
@@ -90,7 +90,7 @@ struct mcheck_hdr {
mcheck_canary canary; /* Magic number to check header integrity. */
};
-static void mcheck_default_abort(enum mcheck_status status)
+static void mcheck_default_abort(enum mcheck_status status, const void *p)
{
const char *msg;
@@ -111,7 +111,7 @@ static void mcheck_default_abort(enum mcheck_status status)
msg = "bogus mcheck_status, library is buggy\n";
break;
}
- printf("\n\nmcheck: %s!!! [%zu]\n\n", msg, mcheck_chunk_count_max);
+ printf("\n\nmcheck: %p:%s!!! [%zu]\n\n", p, msg, mcheck_chunk_count_max);
}
static mcheck_abortfunc_t mcheck_abortfunc = &mcheck_default_abort;
@@ -124,9 +124,9 @@ static inline size_t allign_size_up(size_t sz, size_t grain)
#define mcheck_allign_customer_size(SZ) allign_size_up(SZ, sizeof(mcheck_elem))
#define mcheck_evaluate_memalign_prefix_size(ALIGN) allign_size_up(sizeof(struct mcheck_hdr), ALIGN)
-static enum mcheck_status mcheck_OnNok(enum mcheck_status status)
+static enum mcheck_status mcheck_OnNok(enum mcheck_status status, const void *p)
{
- (*mcheck_abortfunc)(status);
+ (*mcheck_abortfunc)(status, p);
return status;
}
@@ -136,11 +136,11 @@ static enum mcheck_status mcheck_checkhdr(const struct mcheck_hdr *hdr)
for (i = 0; i < CANARY_DEPTH; ++i)
if (hdr->canary.elems[i] == MAGICFREE)
- return mcheck_OnNok(MCHECK_FREE);
+ return mcheck_OnNok(MCHECK_FREE, hdr + 1);
for (i = 0; i < CANARY_DEPTH; ++i)
if (hdr->canary.elems[i] != MAGICWORD)
- return mcheck_OnNok(MCHECK_HEAD);
+ return mcheck_OnNok(MCHECK_HEAD, hdr + 1);
const size_t payload_size = hdr->size;
const size_t payload_size_aligned = mcheck_allign_customer_size(payload_size);
@@ -150,13 +150,13 @@ static enum mcheck_status mcheck_checkhdr(const struct mcheck_hdr *hdr)
for (i = 0; i < padd_size; ++i)
if (payload[payload_size + i] != PADDINGFLOOD)
- return mcheck_OnNok(MCHECK_TAIL);
+ return mcheck_OnNok(MCHECK_TAIL, hdr + 1);
const mcheck_canary *tail = (const mcheck_canary *)&payload[payload_size_aligned];
for (i = 0; i < CANARY_DEPTH; ++i)
if (tail->elems[i] != MAGICTAIL)
- return mcheck_OnNok(MCHECK_TAIL);
+ return mcheck_OnNok(MCHECK_TAIL, hdr + 1);
return MCHECK_OK;
}
diff --git a/include/mcheck.h b/include/mcheck.h
index f4c9b7e61c..bd506ae629 100644
--- a/include/mcheck.h
+++ b/include/mcheck.h
@@ -29,7 +29,7 @@ enum mcheck_status {
MCHECK_TAIL /* Memory after the block was clobbered. */
};
-typedef void (*mcheck_abortfunc_t)(enum mcheck_status);
+typedef void (*mcheck_abortfunc_t)(enum mcheck_status, const void *p);
int mcheck(mcheck_abortfunc_t func);
--
2.25.1
More information about the U-Boot
mailing list