From patchwork Mon Jul 23 20:17:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 10540979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F6B691E for ; Mon, 23 Jul 2018 21:03:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F2712849D for ; Mon, 23 Jul 2018 21:03:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02488284B3; Mon, 23 Jul 2018 21:03:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 869B92849D for ; Mon, 23 Jul 2018 21:03:42 +0000 (UTC) Received: from localhost ([::1]:36613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhzZ-0006j0-G3 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 Jul 2018 17:03:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJf-0002tH-GO for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJe-0004g8-Cw for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:23 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:38117) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJd-0004fm-U5; Mon, 23 Jul 2018 16:20:22 -0400 Received: by mail-oi0-x244.google.com with SMTP id v8-v6so3479693oie.5; Mon, 23 Jul 2018 13:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7x67H7eAhqWAh/LarvuZ2h8gIlqziD8gqtE10KXQacA=; b=fYxoK2nLO/xLTb9w6JgeciQo/NSI1lBpi9m3DZVqDpCP2xp/mPYJkfti1EJlGxjU2/ H7roYDGD+rxdPwuhgJz2pa1HKragfZvnf/M2Mxw4mivo38cBQ2AIskYVoVOo0G1hyjos CyyQSv8dxrhvVt4E7+op32wrnsgiH6yijUowXjWAIsIxzw0XUZGenIfk4+D98z8JrTJj SjHgM2T5j4rXfeEp0nJ/IFOB5VqgzHTLx5JsjUQxixEvKBQBwgT7uQr5G60M/g3OYrlJ 2TQ9jJTJSpMvFClj823xMTU0pdvvWv7bucyDG1oBqAW2y8qxZ6ZAPCLj/0j3atfdibt/ Nz3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7x67H7eAhqWAh/LarvuZ2h8gIlqziD8gqtE10KXQacA=; b=NKdNC1x2lcUSxTkhgzTopXNlGKeu71v3nfre1K9Byq0DDVOHaxQub3XX4ONyJKdPZU t05cPoKTflwELwCYC7T35E3ulAwfRdcQ58cgQo923yrChA+A3Dnngay96YSYyphRu+6X VxJ7N6lqGiDnKUIFaTQG5/r7UEmxOI96GjDFX63Haqg7u6nXvRkECt49uBmdObLmSjDu 2xrSdXOrQIDSiIsLigp2VgWGTsb0LsbH6g8KTkQNox/wVGKLHOSSxbtux+3SXGQa0HSF kA4vx2By6dv0pyzM0/3ygsolqmTaW4i8XpomhzVlV5v05AuBF5hLFXusutzqCuLxKbSO vJrg== X-Gm-Message-State: AOUpUlGstbR4pxnqvI6rRKq7pAx4z+II/+i8Rn0Y/czOhUL3rbrE1fHH YzER19Mztylrw67YW7vGrva1JW8jM4A= X-Google-Smtp-Source: AAOMgpd5isNC6H0jH1ja78cM1R+OuavqFrVhXiVXmtBzA8hLNYAXDvwiVt1xfsST5P9vPUP10WvpgQ== X-Received: by 2002:aca:b256:: with SMTP id b83-v6mr289574oif.235.1532377220725; Mon, 23 Jul 2018 13:20:20 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id e204-v6sm2757327oif.21.2018.07.23.13.20.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:19 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:00 -0500 Message-Id: <20180723201748.25573-52-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 51/99] usb/dev-mtp: Fix use of uninitialized values X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , qemu-stable@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Philippe Mathieu-Daudé This fixes: hw/usb/dev-mtp.c:971:5: warning: 4th function call argument is an uninitialized value trace_usb_mtp_op_get_partial_object(s->dev.addr, o->handle, o->path, c->argv[1], c->argv[2]); ^~~~~~~~~~ and: hw/usb/dev-mtp.c:981:12: warning: Assigned value is garbage or undefined offset = c->argv[1]; ^ ~~~~~~~~~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé Message-id: 20180604151421.23385-3-f4bug@amsat.org Signed-off-by: Gerd Hoffmann (cherry picked from commit 62713a2e50f653162387451034f1a2490e87be88) Signed-off-by: Michael Roth --- hw/usb/dev-mtp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 6ecf70a79b..c50d0bc15e 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -1017,12 +1017,16 @@ static MTPData *usb_mtp_get_object(MTPState *s, MTPControl *c, static MTPData *usb_mtp_get_partial_object(MTPState *s, MTPControl *c, MTPObject *o) { - MTPData *d = usb_mtp_data_alloc(c); + MTPData *d; off_t offset; + if (c->argc <= 2) { + return NULL; + } trace_usb_mtp_op_get_partial_object(s->dev.addr, o->handle, o->path, c->argv[1], c->argv[2]); + d = usb_mtp_data_alloc(c); d->fd = open(o->path, O_RDONLY); if (d->fd == -1) { usb_mtp_data_free(d);