From 6a19ca3254eb2f07c8a77255b78fcc377f44833c Mon Sep 17 00:00:00 2001 From: mbuhl Date: Fri, 8 Apr 2022 13:13:14 +0000 Subject: [PATCH] fix leaking memory in get_sdr on failure. Found by LLVM scan-build. ok sthen@ --- sys/dev/ipmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/dev/ipmi.c b/sys/dev/ipmi.c index 073934ed5df..08726f6956c 100644 --- a/sys/dev/ipmi.c +++ b/sys/dev/ipmi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipmi.c,v 1.117 2022/04/07 17:36:38 sthen Exp $ */ +/* $OpenBSD: ipmi.c,v 1.118 2022/04/08 13:13:14 mbuhl Exp $ */ /* * Copyright (c) 2015 Masao Uebayashi @@ -1398,7 +1398,7 @@ add_child_sensors(struct ipmi_softc *sc, u_int8_t *psdr, int count, int sensor_num, int sensor_type, int ext_type, int sensor_base, int entity, const char *name) { - int typ, idx; + int typ, idx, rc = 0; struct ipmi_sensor *psensor; struct sdrtype1 *s1 = (struct sdrtype1 *)psdr; @@ -1438,11 +1438,12 @@ add_child_sensors(struct ipmi_softc *sc, u_int8_t *psdr, int count, dbg_printf(5, " reading: %lld [%s]\n", psensor->i_sensor.value, psensor->i_sensor.desc); + rc = 1; } else free(psensor, M_DEVBUF, sizeof(*psensor)); } - return (1); + return (rc); } /* Handle IPMI Timer - reread sensor values */ -- 2.20.1