From c010e13b470463928d91a75f51c99b63096d0f42 Mon Sep 17 00:00:00 2001 From: Amarjeet Date: Sat, 20 Jun 2026 17:56:37 +0530 Subject: tools/thermal/thermometer: close fd on realloc() failure thermometer_add_tz() opens tz_path and then reallocates thermometer->tz. If realloc fails, the function returns without closing fd. Close fd before returning on realloc failure to avoid leaking a file descriptor. Signed-off-by: Amarjeet Link: https://patch.msgid.link/20260620122637.1334927-1-amarjeet@intel.com Signed-off-by: Rafael J. Wysocki --- tools/thermal/thermometer/thermometer.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tools') diff --git a/tools/thermal/thermometer/thermometer.c b/tools/thermal/thermometer/thermometer.c index 022865da8e3c..1ae6c3ecedb4 100644 --- a/tools/thermal/thermometer/thermometer.c +++ b/tools/thermal/thermometer/thermometer.c @@ -272,6 +272,7 @@ static int thermometer_add_tz(const char *path, const char *name, int polling, tz = realloc(thermometer->tz, sizeof(*thermometer->tz) * (thermometer->nr_tz + 1)); if (!tz) { ERROR("Failed to allocate thermometer->tz\n"); + close(fd); return -1; } -- cgit