From: Tomas Dzik via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/3] LTP/Lite test float_trigo core dumps due to free(): invalid pointer
Date: Wed, 15 Jul 2026 15:04:46 +0200 [thread overview]
Message-ID: <c2a4d3fb4e65c526dc207aadf2e3f70fec46cc0d.1784119861.git.tdzik@redhat.com> (raw)
In-Reply-To: <cover.1784119861.git.tdzik@redhat.com>
Function read_file() does not initialize *data on failure paths
(for example if malloc() fails) and caller ends up calling SAFE_FREE()
on an uninitialized pointer.
Here is the log from failed run:
~==== float_trigo ====
command: float_trigo -v
float_trigo 0 TINFO : Using /tmp/LTP_floJSug25 as tmpdir (xfs
filesystem)
float_trigo 1 TPASS : Test passed
float_trigo 0 TINFO : float_trigo: will run for 500 loops;
using . as a data directory
float_trigo 0 TINFO : float_trigo: will run 7 functions, 20
threads per function
float_trigo 0 TINFO : signal handler 140451533870784 started
float_trigo 0 TINFO : Signal handler starts waiting...
free(): invalid pointer
Duration: 0.926
This fix initializes pointers where we actually core dumped (*din, *dex).
Signed-off-by: Tomas Dzik <tdzik@redhat.com>
---
testcases/misc/math/float/thread_code.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/testcases/misc/math/float/thread_code.c b/testcases/misc/math/float/thread_code.c
index ca18cef1e..6f3a463dd 100644
--- a/testcases/misc/math/float/thread_code.c
+++ b/testcases/misc/math/float/thread_code.c
@@ -278,7 +278,12 @@ void *thread_code(void *arg)
{
TH_DATA *th_data = (TH_DATA *) arg;
size_t fsize, fsize2, fsize3;
- double *din, *dex, *dex2 = NULL;
+ /*
+ * If read_file() fails for whatever reason, these pointers might
+ * stay uninitialized. Initialize them to NULL, because SAFE_FREE()
+ * can handle it.
+ */
+ double *din = NULL, *dex = NULL, *dex2 = NULL;
int imax, index;
fsize = read_file(th_data->th_func.din_fname, (void **)&din);
--
2.55.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-07-15 13:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 9:45 [LTP] [PATCH 0/3] Fix to float_trigo core dump and related enhancements Tomas Dzik via ltp
2026-07-15 9:45 ` [LTP] [PATCH 1/3] LTP/Lite test float_trigo core dumps due to free(): invalid pointer Tomas Dzik via ltp
2026-07-15 10:55 ` [LTP] " linuxtestproject.agent
2026-07-15 9:45 ` [LTP] [PATCH 2/3] Add some checks for malloc() returning NULL Tomas Dzik via ltp
2026-07-15 9:45 ` [LTP] [PATCH 3/3] Replace sprintf() with more secure snprintf() variant in float tests Tomas Dzik via ltp
2026-07-15 13:04 ` [LTP] [PATCH 0/3] Fix to float_trigo core dump and related enhancements Tomas Dzik via ltp
2026-07-15 13:04 ` Tomas Dzik via ltp
2026-07-15 13:04 ` Tomas Dzik via ltp [this message]
2026-07-15 14:57 ` [LTP] LTP/Lite test float_trigo core dumps due to free(): invalid pointer linuxtestproject.agent
2026-07-15 13:04 ` [LTP] [PATCH 2/3] Add some checks for malloc() returning NULL Tomas Dzik via ltp
2026-07-15 13:04 ` [LTP] [PATCH 3/3] Replace sprintf() with more secure snprintf() variant in float tests Tomas Dzik via ltp
-- strict thread matches above, loose matches on Subject: below --
2026-07-09 15:40 [LTP] [PATCH 0/3] Fix to float_trigo core dump and related enhancements Tomas Dzik via ltp
2026-07-09 15:40 ` [LTP] [PATCH 1/3] LTP/Lite test float_trigo core dumps due to free(): invalid pointer Tomas Dzik via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c2a4d3fb4e65c526dc207aadf2e3f70fec46cc0d.1784119861.git.tdzik@redhat.com \
--to=ltp@lists.linux.it \
--cc=tdzik@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox