From patchwork Thu Sep 14 10:36:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9952737 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 B3D4A603F3 for ; Thu, 14 Sep 2017 10:36:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EA9528E92 for ; Thu, 14 Sep 2017 10:36:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 839C728E94; Thu, 14 Sep 2017 10:36:38 +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 7374D28EAC for ; Thu, 14 Sep 2017 10:36:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751948AbdINKgf (ORCPT ); Thu, 14 Sep 2017 06:36:35 -0400 Received: from mout.web.de ([212.227.17.11]:55182 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751795AbdINKgd (ORCPT ); Thu, 14 Sep 2017 06:36:33 -0400 Received: from [192.168.1.2] ([85.182.44.111]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M1o3y-1dY9T30K1y-00topN; Thu, 14 Sep 2017 12:36:23 +0200 Subject: [PATCH 6/8] [media] ttusb_dec: Reduce the scope for three variables in ttusb_dec_process_urb() From: SF Markus Elfring To: linux-media@vger.kernel.org, Arvind Yadav , Hans Verkuil , Laurent Pinchart , Mauro Carvalho Chehab , Sakari Ailus Cc: LKML , kernel-janitors@vger.kernel.org References: <66b087d3-6dd3-1e1c-d33d-e34c9e2ffe25@users.sourceforge.net> Message-ID: <7c7b66d3-bf34-0635-7941-faeb10854de8@users.sourceforge.net> Date: Thu, 14 Sep 2017 12:36:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <66b087d3-6dd3-1e1c-d33d-e34c9e2ffe25@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:x1CxkarbXSA3wj0zhR/xNUEhTN2c4RLOSPvFWukPOTc5M3/b6f1 KxdRHZfAwpR/SEm/sCvd1ZUoNVC32rhSnY3isC3knP0q1pXWW90uJYQ/SHPCU5LjSJOg4p0 24IPR+80hQjBqMsr9Y0KPCqD2dZIqt8L2RgoAD3JC13dFct0oroOltqL74w3bPvziQrn7Pj 3zd4uIuG/ASht/7CXzkCQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:ek5NFiNcUmE=:6mJEjlgzSWJwUni9wQeaGV /4GfDhyGBJoQcWH3/8V2ZpLOFiilSqxDizzkvTTpCQKEWKv2IVUj8t/cMtDRSaPos8tDR3XnW CZOQd9k2k6FAuRvmRIotDBwAr6qQUl27gTWmdUpNIOixEXia5WiLc8d/YVE9B9Gm7KF3TS5LC 9OpNKSVd29Fgxh51Ki+LOn0kZXNiCmSTunclR/nU5V1nAgsATAGN55IdBErsTUUEvnEjdgDG1 Z5Uc7KxO8VjrhqXlmPsbCP7/AH3tu4yCgRPyg20oN16bklnwonEc6aLxFmXCFiZ9hXGAKs7Tm 5ryvNwXp3eqCMkwmH/qqiOHyFJJD3jWwbPERe7JES1loYc/0bT3WkRbUnPlNk0i2sn8B1a+sD liL8kMcr/oO6ZGJMWjm2OBuwcPlvLn6sycCdz9neGIgBuiuF07fYhXA6q9IiaSRORvmCTAR3u wMG4bcaK/3r98AmDt/iUK75ChmT5ohNtRTZ6o/VM4vt8/M48zTza2M0V9HZlUWAaLfs+CHOfw yi7AQWqvXNIdLcEY0H70qIMlTQ2e5FKsVnJDx5scqE+zMMovbXwzE/ZqBglLhLUhozo76Oyoj oEpP7/ntpeWwzZ40whvNNFyaARKAnwN9SRW8saWaph+A6E42L/RoR5E2dQdKCNAiFV0unBXr0 IsjsmnP7Sw80ZcuWC9w+lp3eTRpgV7I3mu0JFOkivf3zCT/G0DxK+FBkNWoLGvI5oQW43e2bf C5UTSF2Ik6q3S53S4lEv8bDFgCqSYDdRJzOqs89Y+INC9QBjnk7qVRwEXyBJXq/KXgADWq1pG cVau6JBfZejQjqccY4topxhFSUm14IJAMMtxD1pKvhEB1+RwsU= 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: Wed, 13 Sep 2017 21:23:29 +0200 * Move the definition for the local variables "b", "d" and "length" into an if branch so that the corresponding setting will only be performed if a memory allocation succeeded in this function. * Adjust their data types. Signed-off-by: Markus Elfring --- drivers/media/usb/ttusb-dec/ttusb_dec.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c b/drivers/media/usb/ttusb-dec/ttusb_dec.c index 7759de653ee9..e9fe4c6142a5 100644 --- a/drivers/media/usb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c @@ -812,19 +812,18 @@ static void ttusb_dec_process_urb(struct urb *urb) int i; for (i = 0; i < FRAMES_PER_ISO_BUF; i++) { - struct usb_iso_packet_descriptor *d; - u8 *b; - int length; struct urb_frame *frame; - d = &urb->iso_frame_desc[i]; - b = urb->transfer_buffer + d->offset; - length = d->actual_length; - frame = kmalloc(sizeof(*frame), GFP_ATOMIC); if (frame) { unsigned long flags; + struct usb_iso_packet_descriptor const *d; + u8 const *b; + unsigned int length; + d = &urb->iso_frame_desc[i]; + b = urb->transfer_buffer + d->offset; + length = d->actual_length; memcpy(frame->data, b, length); frame->length = length;