[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL 2/4] usb-mtp: fix some usb_mtp_write_data return
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PULL 2/4] usb-mtp: fix some usb_mtp_write_data return paths |
Date: |
Fri, 8 Mar 2019 17:37:06 +0000 |
On Thu, 7 Mar 2019 at 09:58, Gerd Hoffmann <address@hidden> wrote:
>
> From: Bandan Das <address@hidden>
>
> During a write, free up the "path" before getting more data.
> Also, while we at it, remove the confusing usage of d->fd for
> storing mkdir status
>
> Spotted by Coverity: CID 1398642
>
> Signed-off-by: Bandan Das <address@hidden>
> Message-id: address@hidden
> Signed-off-by: Gerd Hoffmann <address@hidden>
Hi; Coverity found an issue with the code change here
(CID 1399415):
> index 4dde14fc7887..1f22284949df 100644
> --- a/hw/usb/dev-mtp.c
> +++ b/hw/usb/dev-mtp.c
> @@ -1605,7 +1605,7 @@ static int usb_mtp_update_object(MTPObject *parent,
> char *name)
> return ret;
> }
>
> -static void usb_mtp_write_data(MTPState *s)
> +static int usb_mtp_write_data(MTPState *s)
Here we change usb_mtp_write_data() to return an error code...
> {
> MTPData *d = s->data_out;
> MTPObject *parent =
> @@ -1727,14 +1731,12 @@ static void usb_mtp_write_metadata(MTPState *s,
> uint64_t dlen)
> s->write_pending = true;
>
> if (s->dataset.format == FMT_ASSOCIATION) {
> - usb_mtp_write_data(s);
> - /* next_handle will be allocated to the newly created dir */
> - if (d->fd == -1) {
> + if (usb_mtp_write_data(s)) {
> + /* next_handle will be allocated to the newly created dir */
> usb_mtp_queue_result(s, RES_STORE_FULL, d->trans,
> 0, 0, 0, 0);
> return;
...and we updated this callsite to check the error return value.
But the two places in usb_mtp_get_data() that call
usb_mtp_write_metadata() still don't check its return
value: don't they need to handle failure too?
thanks
-- PMM
- [Qemu-devel] [PULL 0/4] Usb 20190307 patches, Gerd Hoffmann, 2019/03/07
- [Qemu-devel] [PULL 1/4] usb-mtp: return incomplete transfer on a lstat failure, Gerd Hoffmann, 2019/03/07
- [Qemu-devel] [PULL 4/4] Introduce new "no_guest_reset" parameter for usb-host device, Gerd Hoffmann, 2019/03/07
- [Qemu-devel] [PULL 2/4] usb-mtp: fix some usb_mtp_write_data return paths, Gerd Hoffmann, 2019/03/07
- Re: [Qemu-devel] [PULL 2/4] usb-mtp: fix some usb_mtp_write_data return paths,
Peter Maydell <=
- Re: [Qemu-devel] [PULL 2/4] usb-mtp: fix some usb_mtp_write_data return paths, Bandan Das, 2019/03/08
- Re: [Qemu-devel] [PULL 2/4] usb-mtp: fix some usb_mtp_write_data return paths, Peter Maydell, 2019/03/14
- Re: [Qemu-devel] [PULL 2/4] usb-mtp: fix some usb_mtp_write_data return paths, Bandan Das, 2019/03/15
- Re: [Qemu-devel] [PULL 2/4] usb-mtp: fix some usb_mtp_write_data return paths, Peter Maydell, 2019/03/18
- Re: [Qemu-devel] [PULL 2/4] usb-mtp: fix some usb_mtp_write_data return paths, Bandan Das, 2019/03/18
[Qemu-devel] [PULL 3/4] usb-mtp: prevent null dereference while deleting objects, Gerd Hoffmann, 2019/03/07