qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coverity CID 1421984


From: BALATON Zoltan
Subject: Re: Coverity CID 1421984
Date: Mon, 23 Mar 2020 16:28:07 +0100 (CET)
User-agent: Alpine 2.22 (BSF 395 2020-01-19)

On Mon, 23 Mar 2020, Peter Maydell wrote:
On Mon, 23 Mar 2020 at 14:43, BALATON Zoltan <address@hidden> wrote:
On Mon, 23 Mar 2020, Peter Maydell wrote:
On Mon, 23 Mar 2020 at 14:06, BALATON Zoltan <address@hidden> wrote:
On Mon, 23 Mar 2020, Peter Maydell wrote:
Coverity has flagged up a lot of leaks involving qemu_allocate_irqs();
most of them I've for the moment just set as "insignificant, fix
required" because they're in called-once functions like board init.
If this device can't be hot-unplugged and so we will only ever call
realize once, it would fall in that category too. Otherwise I'd
suggest conversion to qdev_init_gpio_in(). (This allocates arrays
of IRQs under the hood too, but the device_finalize() function will
automatically free them for you, so it's easier to use non-leakily.)

I think I can't do that in sii3112 becuase I need to pass irq to this func:

void ide_init2(IDEBus *bus, qemu_irq irq);

ide_init2(bus, qdev_get_gpio_in(DEVICE(dev), i);

should do what you want, I think.

I don't understand what you mean.

I mean that if you allocate the IRQs with qdev_init_gpio_in()
then the way to get a qemu_irq from within them to pass
to another function is to call qdev_get_gpio_in(). So you
just want to make your call to ide_init2() be the line I
suggest above.

Is this documented anywhere? Even after this reply I did not understand until I saw your patch. (And even after that I'm not quite sure when and how to use gpios so probably this should be made a bit more clear in docs or somewhere.)

Problem is that there are no complete docs so people are directed to look at the code. But the code is full of bad examples (like ahci and cmd646 in this case) so can't find out what's the latest preferred way. At least a list of preferred vs. legacy functions/APIs should exist somewhere and the preferred ones should be documented. Irq handling and gpios is one of the mysteries that are hard to get so some info on that would help.

Thanks for fixing this.

Regards,
BALATON Zoltan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]