From: Eugene Uriev Date: Sun, 31 Mar 2024 20:03:27 +0000 (+0300) Subject: mcheck: let mcheck_abortfunc_t print the pointer X-Git-Url: http://git.dujemihanovic.xyz/html/static/git-favicon.png?a=commitdiff_plain;h=707a6dfb2b8429b3d361c8c884ada48ebae6f1e4;p=u-boot.git mcheck: let mcheck_abortfunc_t print the pointer Signed-off-by: Eugene Uriev --- 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);