On Tue, May 30, 2023 at 05:02:26PM +0200, Ján Tomko wrote:
In virNodeDeviceGetSCSIHostCaps, there is a pattern of reusing a tmp value and stealing the pointer. But in one case it is not stolen. Use a separate variable for it to avoid mixing autofree with manual free() calls.
Actually in two cases, there's one right below with npiv_vports_inuse.
Fixes: 8a0cb5f73ade3900546718eabe70cb064c6bd22c Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/conf/node_device_conf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index fcee9c027c..2c98844c47 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2858,15 +2858,16 @@ virNodeDeviceGetSCSIHostCaps(virNodeDevCapSCSIHost *scsi_host) if (virVHBAIsVportCapable(NULL, scsi_host->host)) { scsi_host->flags |= VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS; + g_autofree char *max_vports = NULL; - if (!(tmp = virVHBAGetConfig(NULL, scsi_host->host, + if (!(max_vports = virVHBAGetConfig(NULL, scsi_host->host, "max_npiv_vports"))) { VIR_WARN("Failed to read max_npiv_vports for host%d", scsi_host->host); goto cleanup; } - if (virStrToLong_i(tmp, NULL, 10, &scsi_host->max_vports) < 0) { + if (virStrToLong_i(max_vports, NULL, 10, &scsi_host->max_vports) < 0) { VIR_WARN("Failed to parse value of max_npiv_vports '%s'", tmp); goto cleanup; } -- 2.40.1
Attachment:
signature.asc
Description: PGP signature