Re: [PATCH v2] KVM: fix memory leak in kvm_io_bus_unregister_dev()

From: Gustavo A. R. Silva
Date: Fri Sep 04 2020 - 10:31:57 EST


On Fri, Sep 04, 2020 at 02:04:23PM +0200, Vitaly Kuznetsov wrote:
> Rustam Kovhaev <rkovhaev@xxxxxxxxx> writes:
>
> > On Wed, Sep 02, 2020 at 06:34:11PM -0500, Gustavo A. R. Silva wrote:
> >> Hi,
> >>
> >> On 9/2/20 17:57, Rustam Kovhaev wrote:
> >> > when kmalloc() fails in kvm_io_bus_unregister_dev(), before removing
> >> > the bus, we should iterate over all other devices linked to it and call
> >> > kvm_iodevice_destructor() for them
> >> >
> >> > Reported-and-tested-by: syzbot+f196caa45793d6374707@xxxxxxxxxxxxxxxxxxxxxxxxx
> >> > Link: https://syzkaller.appspot.com/bug?extid=f196caa45793d6374707
> >> > Signed-off-by: Rustam Kovhaev <rkovhaev@xxxxxxxxx>
> >> > Reviewed-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
> >>
> >> I think it's worthwhile to add a Fixes tag for this, too.
> >>
> >> Please, see more comments below...
[..]
> >
> > hi Gustavo, thank you for the review, i'll send the new patch.
> > Vitaly, i think i will need to drop your "Reviewed-by", because there is
> > going to be a bit more changes
> >
>
> Personally, I'd prefer to make struct_size()/flex_array_size() a
> separate preparatory patch so the real fix is small but I don't have a
> strong opinion. I'll take look at v3 so feel free to drop R-b if you
> decide to make a combined patch and feel free to keep it if you make the
> preparatory changes separate :-)
>

I agree. A two-patch series is much better in this case.

Rustam - please add a Fixes tag to the first patch and see if it can be
applied to -stable. If so, you should Cc stable@xxxxxxxxxxxxxxx, too.

Thanks
--
Gustavo