From patchwork Mon Dec 26 20:50:05 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: 9488793 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 4300E62AAD for ; Mon, 26 Dec 2016 20:51:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35CAC1FF35 for ; Mon, 26 Dec 2016 20:51:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 257741FF60; Mon, 26 Dec 2016 20:51:13 +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 CF4A71FF60 for ; Mon, 26 Dec 2016 20:51:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754916AbcLZUvF (ORCPT ); Mon, 26 Dec 2016 15:51:05 -0500 Received: from mout.web.de ([212.227.17.12]:58093 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751918AbcLZUvE (ORCPT ); Mon, 26 Dec 2016 15:51:04 -0500 Received: from [192.168.1.2] ([77.182.133.191]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LeLWz-1ctMkx3Gu5-00q8bf; Mon, 26 Dec 2016 21:50:10 +0100 Subject: [PATCH 5/8] [media] videobuf-dma-sg: Move two assignments for error codes in __videobuf_mmap_mapper() To: linux-media@vger.kernel.org, Dave Hansen , Jan Kara , Javier Martinez Canillas , "Kirill A. Shutemov" , Lorenzo Stoakes , Mauro Carvalho Chehab , Michal Hocko , Sakari Ailus References: <9268b60d-08ba-c64e-1848-f84679d64f80@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Mon, 26 Dec 2016 21:50:05 +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: <9268b60d-08ba-c64e-1848-f84679d64f80@users.sourceforge.net> X-Provags-ID: V03:K0:gOqE/yomXmYyQNZkeKQHwW7rpKSwW9dbAb4Xa5+xegwnOhsdUAX WT6MtBLJLnbFCYICeTsI9AYN2/n6d8l0tSHDmMlafXTN/jFQa8pGDQW3X0IBNfH5te71Of0 DduHRIfYqtz22to2A7WMCmYFG5zmz/YiiLFrWVn2dAnEVgpZ+zmZi5T5KfVjRSmDmH0H7RT Rb5EdU6cYZkeXRoy2SvoQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:euNnj5q8+/8=:utAjwfeNk9dHwoyNmqY576 84yDEysMsOEiGkcAiyIJzTlU4yaGy5vclx5Yf4y2v75VbFS+xwLnVdMiGe75My3p9sZgxwz1E OZokqTYjtjIy42HOikJnOicn7CjoBIRTjjNl7oEnfOhZvL4csbq4CACSwcFh/om3Bm1G+Ru4C gCiuCgoyRbEdma9NEKqO7sWZGM6hLYfKdKni/KXCAE3nOJ3wVY4qPtbyRYUAEYu3bmZMltogr 1d9L/L3OpXdSnKQqU89u5dpRnFeaQJY2/kOU8mQ/QoIAKbp76KqhVfXditsnNYqnNSB/5R4hD +rZT8KiPy6pCTX+5hDouIKPy/Iz0mZ0QNbG5lX/aiCoqj96ynhXtWf0V8e7ZCerIBMl3tAYxA K5qqCyR7FI7NqqO7qET40UNdGu/BwpR9AETesl3SS0BTfvhUKvycPdM0BZJrjUbGDvIZudInw nbONwaqjh5O5N/BHcS6CxOK1ty7IX0BXPPF855/1wfisXJ3/DJz4ck3js9rZV2Q3Ne3tL3LQa Rjykvn8KhsGNC5hQRLx4OzbeUDuSgftFGrOQJNvnIDum59iXf/5ICve61v2m5XLwcIqjDrxzd wtt8RBH0GRPoIwSE6jjsI0o6/e+doEdZJ/EjP5EsOkLDRj8UAbiAMi+/b7lI6EraASi3GKbpV 1wK+Nf8NAMWD3nl+261Pnom2WacjjVd0HfK5aFY4AnX8KzZv1RXsDbbF1A9o6aN4SjA3vjn4B tmtITkWjskixzagDdtyYePz1BOKk3rqBlCI67A/fSzMNDRKH7FQ+aNYIWj4363fHpciKXx3IN R/XYKeA 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: Mon, 26 Dec 2016 20:48:50 +0100 Move two assignments for the local variable "retval" so that these statements will only be executed if a previous action failed in this function. Signed-off-by: Markus Elfring --- drivers/media/v4l2-core/videobuf-dma-sg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2-core/videobuf-dma-sg.c index 9ccdc11aa016..d09ddf2e56fe 100644 --- a/drivers/media/v4l2-core/videobuf-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf-dma-sg.c @@ -596,8 +596,6 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, unsigned int first, last, size = 0, i; int retval; - retval = -EINVAL; - BUG_ON(!mem); MAGIC_CHECK(mem->magic, MAGIC_SG_MEM); @@ -613,16 +611,18 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, if (!size) { dprintk(1, "mmap app bug: offset invalid [offset=0x%lx]\n", (vma->vm_pgoff << PAGE_SHIFT)); + retval = -EINVAL; goto done; } last = first; /* create mapping + update buffer list */ - retval = -ENOMEM; map = kmalloc(sizeof(struct videobuf_mapping), GFP_KERNEL); - if (!map) + if (!map) { + retval = -ENOMEM; goto done; + } size = 0; for (i = first; i <= last; i++) {