From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:47408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2cej-0004lA-HE for qemu-devel@nongnu.org; Sat, 09 Mar 2019 09:08:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2ceh-00030y-LF for qemu-devel@nongnu.org; Sat, 09 Mar 2019 09:08:52 -0500 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]:45471) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2ceg-0002xD-JS for qemu-devel@nongnu.org; Sat, 09 Mar 2019 09:08:51 -0500 Received: by mail-oi1-x22b.google.com with SMTP id t82so327678oie.12 for ; Sat, 09 Mar 2019 06:08:48 -0800 (PST) MIME-Version: 1.0 References: <20190307095441.31921-1-kraxel@redhat.com> <20190307095441.31921-4-kraxel@redhat.com> In-Reply-To: From: Peter Maydell Date: Sat, 9 Mar 2019 14:08:36 +0000 Message-ID: Content-Type: text/plain; charset="UTF-8" Subject: Re: [Qemu-devel] [PULL 3/4] usb-mtp: prevent null dereference while deleting objects List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bandan Das Cc: Gerd Hoffmann , QEMU Developers On Fri, 8 Mar 2019 at 19:46, Bandan Das wrote: > This is very broken! I think something like this should work: > diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c > index 06e376bcd2..87a4bfb415 100644 > --- a/hw/usb/dev-mtp.c > +++ b/hw/usb/dev-mtp.c > @@ -1138,8 +1138,8 @@ static MTPData *usb_mtp_get_object_prop_value(MTPState *s, MTPControl *c, > /* Return correct return code for a delete event */ > enum { > ALL_DELETE, > - PARTIAL_DELETE, > READ_ONLY, > + PARTIAL_DELETE, > }; This is defining these values as an incrementing series... > if (o->format == FMT_UNDEFINED_OBJECT) { > if (remove(o->path)) { > - partial_delete = true; > + ret |= READ_ONLY; > } else { > usb_mtp_object_free_one(s, o); > - success = true; > + ret |= ALL_DELETE; ...but here we're using them as bits which we OR together. In particular ALL_DELETE is 0, so ORing it in will do nothing. thanks -- PMM