Skip to content

Commit 4950ecd

Browse files
committed
ocp: fix to free hwcomp log desc memory allocated
Since the desc pointer used _cleanup_free_ only set NULL value. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent eea4913 commit 4950ecd

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

plugins/ocp/ocp-hardware-component-log.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,10 @@ static int get_hwcomp_log_data(struct nvme_dev *dev, struct hwcomp_log *log)
241241

242242
static int get_hwcomp_log(struct nvme_dev *dev, __u32 id, bool list)
243243
{
244-
_cleanup_free_ __u8 *desc = NULL;
245-
246244
int ret;
247245
nvme_print_flags_t fmt;
248246
struct hwcomp_log log = {
249-
.desc = (struct hwcomp_desc *)desc,
247+
.desc = NULL,
250248
};
251249

252250
ret = validate_output_format(nvme_cfg.output_format, &fmt);
@@ -256,15 +254,15 @@ static int get_hwcomp_log(struct nvme_dev *dev, __u32 id, bool list)
256254
}
257255

258256
ret = get_hwcomp_log_data(dev, &log);
259-
if (ret) {
257+
if (ret)
260258
print_info_error("error: ocp: failed get hwcomp log: %02X data, ret: %d\n",
261259
OCP_LID_HWCOMP, ret);
262-
return ret;
263-
}
260+
else
261+
ocp_show_hwcomp_log(&log, id, list, fmt);
264262

265-
ocp_show_hwcomp_log(&log, id, list, fmt);
263+
free(log.desc);
266264

267-
return 0;
265+
return ret;
268266
}
269267

270268
int ocp_hwcomp_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)

0 commit comments

Comments
 (0)