Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: krishnaveni.palanisamy@intel.com
To: igt-dev@lists.freedesktop.org
Cc: sk.anirban@intel.com, kamil.konieczny@intel.com,
	riana.tauro@intel.com, anshuman.gupta@intel.com,
	Krishnaveni Palanisamy <krishnaveni.palanisamy@intel.com>
Subject: [PATCH] tests/intel/perf_pmu: Fix double free of drpc in test_rc6
Date: Wed,  9 Sep 2026 11:22:36 +0530	[thread overview]
Message-ID: <20260909055236.52492-1-krishnaveni.palanisamy@intel.com> (raw)

From: Krishnaveni Palanisamy <krishnaveni.palanisamy@intel.com>

test_rc6() frees the 'drpc' buffer returned by igt_sysfs_get() at the
end of each phase (initial wakeup, post-S3, post-idle) but leaves the
pointer dangling. If a subsequent phase is skipped or returns early,
the same pointer could be freed again, resulting in a
"double free detected in tcache" abort from glibc when the test exits.

Set drpc to NULL after each free() so the pointer cannot be reused
accidentally.

Signed-off-by: Krishnaveni Palanisamy <krishnaveni.palanisamy@intel.com>
---
 tests/intel/perf_pmu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/intel/perf_pmu.c b/tests/intel/perf_pmu.c
index 1e389958f..f48e1af57 100644
--- a/tests/intel/perf_pmu.c
+++ b/tests/intel/perf_pmu.c
@@ -1766,6 +1766,7 @@ test_rc6(int gem_fd, unsigned int gt, unsigned int num_gt, unsigned int flags)
 					    ts[1] - ts[0],
 					    tolerance, drpc);
 		free(drpc);
+		drpc=NULL;
 	}
 
 	if (flags & TEST_S3) {
@@ -1806,6 +1807,7 @@ test_rc6(int gem_fd, unsigned int gt, unsigned int num_gt, unsigned int flags)
 					    ts[1] - ts[0],
 					    tolerance, drpc);
 		free(drpc);
+		drpc=NULL;
 	}
 
 	/* Wake up device and check no RC6. */
@@ -1847,6 +1849,7 @@ test_rc6(int gem_fd, unsigned int gt, unsigned int num_gt, unsigned int flags)
 						    ts[1] - ts[0],
 						    tolerance, drpc);
 		free(drpc);
+		drpc=NULL;
 	}
 }
 
-- 
2.53.0


             reply	other threads:[~2026-09-09 16:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09  5:52 krishnaveni.palanisamy [this message]
2026-09-09 20:28 ` ✓ Xe.CI.BAT: success for tests/intel/perf_pmu: Fix double free of drpc in test_rc6 (rev3) Patchwork
2026-09-09 21:17 ` ✓ i915.CI.BAT: " Patchwork
2026-09-10  7:53 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-09-10 15:01 ` ✗ i915.CI.Full: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2026-09-09  6:29 [PATCH] tests/intel/perf_pmu: Fix double free of drpc in test_rc6 krishnaveni.palanisamy
2026-09-09  8:23 ` Anirban, Sk

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=20260909055236.52492-1-krishnaveni.palanisamy@intel.com \
    --to=krishnaveni.palanisamy@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@intel.com \
    --cc=riana.tauro@intel.com \
    --cc=sk.anirban@intel.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