hw/cxl: cdat: Fix failure to free buffer in erorr paths
commit7b22a3218ad0b8388c8bf20d394e3220b2fc8798
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Fri, 21 Apr 2023 13:20:20 +0000 (21 14:20 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 19 May 2023 05:36:09 +0000 (19 01:36 -0400)
treef245d8f67b76d44434c91a1f5578423d25655c74
parent71ba92f3488b64bd5c81e2872c56e88cea21bb95
hw/cxl: cdat: Fix failure to free buffer in erorr paths

The failure paths in CDAT file loading did not clear up properly.
Change to using g_auto_free and a local pointer for the buffer to
ensure this function has no side effects on error.
Also drop some unnecessary checks that can not fail.

Cleanup properly after a failure to load a CDAT file.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Message-Id: <20230421132020.7408-3-Jonathan.Cameron@huawei.com>
Reviewed-by: Fan Ni <fan.ni@samsung.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/cxl/cxl-cdat.c
hw/mem/cxl_type3.c
hw/pci-bridge/cxl_upstream.c