diff options
author | Peter Maydell | 2019-07-02 18:38:44 +0200 |
---|---|---|
committer | Gerd Hoffmann | 2019-07-03 10:51:35 +0200 |
commit | 41742927ee37527462a13160380860653d4f1c84 (patch) | |
tree | 41744da1198ff76741c61bba6a7aa33e95b59f04 /include/hw/i2c/ppc4xx_i2c.h | |
parent | virtio-gpu: check if the resource already exists in virtio_gpu_load() (diff) | |
download | qemu-41742927ee37527462a13160380860653d4f1c84.tar.gz qemu-41742927ee37527462a13160380860653d4f1c84.tar.xz qemu-41742927ee37527462a13160380860653d4f1c84.zip |
hw/i2c/bitbang_i2c: Use in-place rather than malloc'd bitbang_i2c_interface struct
Currently the bitbang_i2c_init() function allocates a
bitbang_i2c_interface struct which it returns. This is unfortunate
because it means that if the function is used from a DeviceState
init method then the memory will be leaked by an "init then delete"
cycle, as used by the qmp/hmp commands that list device properties.
Since three out of four of the uses of this function are in
device init methods, switch the function to do an in-place
initialization of a struct that can be embedded in the
device state struct of the caller.
This fixes LeakSanitizer leak warnings that have appeared in the
patchew configuration (which only tries to run the sanitizers
for the x86_64-softmmu target) now that we use the bitbang-i2c
code in an x86-64 config.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
Tested-by: BALATON Zoltan <balaton@eik.bme.hu>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20190702163844.20458-1-peter.maydell@linaro.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'include/hw/i2c/ppc4xx_i2c.h')
-rw-r--r-- | include/hw/i2c/ppc4xx_i2c.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/hw/i2c/ppc4xx_i2c.h b/include/hw/i2c/ppc4xx_i2c.h index 8437bf070b..f6f837fbec 100644 --- a/include/hw/i2c/ppc4xx_i2c.h +++ b/include/hw/i2c/ppc4xx_i2c.h @@ -41,7 +41,7 @@ typedef struct PPC4xxI2CState { I2CBus *bus; qemu_irq irq; MemoryRegion iomem; - bitbang_i2c_interface *bitbang; + bitbang_i2c_interface bitbang; int mdidx; uint8_t mdata[4]; uint8_t lmadr; |