From patchwork Sun Dec 25 18:44:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9488311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BBCE1601D7 for ; Sun, 25 Dec 2016 18:44:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B66AE205B0 for ; Sun, 25 Dec 2016 18:44:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA9BD25250; Sun, 25 Dec 2016 18:44:52 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59F13205B0 for ; Sun, 25 Dec 2016 18:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754246AbcLYSoc (ORCPT ); Sun, 25 Dec 2016 13:44:32 -0500 Received: from mout.web.de ([217.72.192.78]:49960 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754097AbcLYSob (ORCPT ); Sun, 25 Dec 2016 13:44:31 -0500 Received: from [192.168.1.2] ([77.182.80.223]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Mf0cv-1cAYYS2bO5-00OYLg; Sun, 25 Dec 2016 19:44:25 +0100 Subject: [PATCH 12/19] [media] uvc_driver: Move six assignments in uvc_parse_streaming() To: linux-media@vger.kernel.org, Laurent Pinchart , Mauro Carvalho Chehab References: <47aa4314-74ec-b2bf-ee3b-aad4d6e9f0a2@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Sun, 25 Dec 2016 19:44:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <47aa4314-74ec-b2bf-ee3b-aad4d6e9f0a2@users.sourceforge.net> X-Provags-ID: V03:K0:gzujebf1Xf7kjFhozhZHLqt8CZQaMWW0lauzJ66o3UeDSrS2PE4 xsiNOTpiMAf5YGV6Tod1DT4Q+i54vcoX8RQ/BfeusB5DCNg6mDbVdqFxah9ATuVKPfDQrP8 tER0ULGobJXkFZuSJnd1BKWrAqEqvXbTxBPYdAHd2Liq5LEX6qf1GjeNovi6aZQY823YLpI R+iBbnYplOGoOLqkI0YSA== X-UI-Out-Filterresults: notjunk:1; V01:K0:QzOKItO6Smw=:Tr37JVqcEVM8GOjsIFFiGm AnHxjAUDPIJcjYYuT/O6UuTzGfgoqzuKQ4P/5UTzi0mTqjoMB36TNQ0+1HsohX4329O8tvFS0 7XMWO9enCLr2k4hgYlEV+2udytmP7ty5cPTheebrpxTmBqDkYxdkVl3/ffdYYgCQZCXol6ghP lgDFvtNjkkpwu3o8RslcsIlLUH3sN/8t4VMsYiLotfbz5paS6fMzNAdKTSKXpxEH2xLZkAnyH FwiwDvnwP1q1wmQsUKFyFTocdYVWAAv2NlOFG3Fk/ArF6XxkXQiPYFAKnL94sDBBwzVnx9OgZ tsYM9SqTZzVoyQ+AYZQJsB4uFzczw+A+NOZOOd7Y59bwzpx9l1asHwHVuIHC3aiDJgFz4U0U4 2vekJiTkU6tBBJNLJPPhXWp9vk5KeSTyGWHO4umcodYL7bepn0xHfhq2yLaG254ncn9oCaesf hNFZGZjHRw+7Db7pgURaeSFc+0OVrJ6olX+Z5e80MB2qrdSkqrA/8XlLEctNdJ/ThUlj7xduZ C9oy3vQUWYRm+hqUd3z1FcMZDUNv/fZoIbfn6JUV1ArIUPxC9vZHTx767Me+nXi1iJ3+bgIUl A5gKdQF9JdEIuKXiP+BJUmlNhFSprUapf3ilST9bxQ4NW9KGMf18g23ewxrG8MDiSIFTYyNm2 ysm1ZHMr4+LAvJ+NpH/koOZl3BFFWTKofVrwroKcRL9gcj356CPYnjKnNMSBk5he+QBzK1cOR GJrenqF4ZXQEvCnkwyk+Z5B71gE+xuEVoxLRryRkpQE7jqzAM5GNCYxnTsmJLwxoBB/v3kDbn TUX53Rs Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 25 Dec 2016 16:25:57 +0100 Move the assignments for six local variables so that these statements will only be executed if memory allocations succeeded by this function. Signed-off-by: Markus Elfring --- drivers/media/usb/uvc/uvc_driver.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 5bb18a5f7d9f..d67fd5dfb335 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -634,11 +634,10 @@ static int uvc_parse_streaming(struct uvc_device *dev, struct uvc_streaming *streaming; struct uvc_format *format; struct uvc_frame *frame; - struct usb_host_interface *alts = &intf->altsetting[0]; - unsigned char *_buffer, *buffer = alts->extra; - int _buflen, buflen = alts->extralen; - unsigned int nformats = 0, nframes = 0, nintervals = 0; - unsigned int size, i, n, p; + struct usb_host_interface *alts; + unsigned char *_buffer, *buffer; + int _buflen, buflen; + unsigned int nformats, nframes, nintervals, size, i, n, p; __u32 *interval; __u16 psize; int ret = -EINVAL; @@ -670,6 +669,9 @@ static int uvc_parse_streaming(struct uvc_device *dev, streaming->dev = dev; streaming->intf = usb_get_intf(intf); streaming->intfnum = intf->cur_altsetting->desc.bInterfaceNumber; + alts = &intf->altsetting[0]; + buffer = alts->extra; + buflen = alts->extralen; /* The Pico iMage webcam has its class-specific interface descriptors * after the endpoint descriptors. @@ -759,6 +761,9 @@ static int uvc_parse_streaming(struct uvc_device *dev, _buffer = buffer; _buflen = buflen; + nformats = 0; + nframes = 0; + nintervals = 0; /* Count the format and frame descriptors. */ while (_buflen > 2 && _buffer[1] == USB_DT_CS_INTERFACE) {