From: "Tommaso Califano" <tcalifano@redhat.com>
To: <marcandre.lureau@redhat.com>, "Tommaso Califano" <tcalifano@redhat.com>
Cc: <qemu-devel@nongnu.org>, "Markus Armbruster" <armbru@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Junjie Cao" <junjie.cao@linux.dev>, <qemu-stable@nongnu.org>
Subject: Re: [PATCH 2/9] hw/usb/dev-mtp: Reset pending write state on cancel, reset and error
Date: Fri, 13 Nov 2026 12:46:59 +0100 [thread overview]
Message-ID: <DMU24DRY7JM0.1VG242UKW6HJO@redhat.com> (raw)
In-Reply-To: <179455878071.754321.2481506478534104185.b4-review@b4>
On Fri Nov 13, 2026 at 9:33 AM CET, marcandre.lureau wrote:
>> The pending state (s->dataset.filename, s->data_out, s->write_pending)
>> was only partially released when a transaction was canceled, the session
>> closed, the device reset, or the write failed. This left dangling
>> pointers and leaked memory.
>>
>> Free and clear these fields consistently on all those paths, and route
>> the early error in usb_mtp_write_data() through the common cleanup.
>>
>> Cc: qemu-stable@nongnu.org
>> Fixes: 53735bef108c ("usb-mtp: Advertise SendObjectInfo for write support")
>> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4529
>> Suggested-by: Hui Peng <https://gitlab.com/benquike>
>> Signed-off-by: Tommaso Califano <tcalifano@redhat.com>
>> Message-ID: <20261112174907.158825-3-tcalifano@redhat.com>
>> ---
>> hw/usb/dev-mtp.c | 22 +++++++++++++++-------
>> 1 file changed, 15 insertions(+), 7 deletions(-)
>>
>> diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
>> index bc5a6f089178..1c14770a9c05 100644
>> --- a/hw/usb/dev-mtp.c
>> +++ b/hw/usb/dev-mtp.c
>> @@ -1236,6 +1236,13 @@ static void usb_mtp_object_delete(MTPState *s, uint32_t handle,
>> }
>> }
>>
>> +static void usb_mtp_reset_pending_write(MTPState *s) {
>
> QEMU C style puts the opening brace of a function definition on its own line.
>
Yes, sorry I miss that.
>> + g_free(s->dataset.filename);
>> + s->dataset.filename = NULL;
>> + s->write_pending = false;
>> + s->dataset.size = 0;
>
> Consider also clearing dataset.format and dataset.parent_handle here.
I'll check it.
Thanks,
Tommaso
next prev parent reply other threads:[~2026-11-13 11:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 17:48 [PATCH 0/9] hw/usb/dev-mtp: Collection of bug fixes Tommaso Califano
2026-11-12 17:48 ` [PATCH 1/9] hw/usb/dev-mtp: Fix recursive delete of directories Tommaso Califano
2026-11-12 17:48 ` [PATCH 2/9] hw/usb/dev-mtp: Reset pending write state on cancel, reset and error Tommaso Califano
2026-11-13 8:33 ` marcandre.lureau
2026-11-13 11:46 ` Tommaso Califano [this message]
2026-11-12 17:49 ` [PATCH 3/9] hw/usb/dev-mtp: Check length of class control request Tommaso Califano
2026-11-13 8:33 ` marcandre.lureau
2026-11-12 17:49 ` [PATCH 4/9] hw/usb/dev-mtp: Handle invalid characters in utf16_to_str() Tommaso Califano
2026-11-13 8:33 ` marcandre.lureau
2026-11-12 17:49 ` [PATCH 5/9] hw/usb/dev-mtp: Validate container length on first data packet Tommaso Califano
2026-11-13 8:33 ` marcandre.lureau
2026-11-12 17:49 ` [PATCH 6/9] hw/usb/dev-mtp: Detect end of SendObject data correctly Tommaso Califano
2026-11-12 17:49 ` [PATCH 7/9] hw/usb/dev-mtp: Zero-initialize command and params in handle_data Tommaso Califano
2026-11-12 17:49 ` [PATCH 8/9] hw/usb/dev-mtp: Fix assert failures in usb_mtp_write_metadata() Tommaso Califano
2026-11-12 17:49 ` [PATCH 9/9] hw/usb/dev-mtp: Stop processing SendObjectInfo after an error Tommaso Califano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DMU24DRY7JM0.1VG242UKW6HJO@redhat.com \
--to=tcalifano@redhat.com \
--cc=armbru@redhat.com \
--cc=junjie.cao@linux.dev \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.