Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3896727ima; Mon, 4 Feb 2019 07:01:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN5us7TYtS5b0hnJJXSVlV2uSZ+t8H+DfVFcbFu1hlfK0AAcPMCwAcLObvjWzYKhN5jBh17l X-Received: by 2002:a17:902:654a:: with SMTP id d10mr50802941pln.324.1549292519583; Mon, 04 Feb 2019 07:01:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549292519; cv=none; d=google.com; s=arc-20160816; b=iGFqrNpQIR8UJKaRM5BF+u2U8bg1f2IquS9PMh3bBXM3kDvTodYVJ8+PMA0EgotAZP 3sfOUEkAXJvXeFr5jiEawWX7WV8dytQA2uWAqruWsmtjQoeTbf7ychE+stDqe3r0FSF3 Zyj48l5eAGw7uOEEyi0OU0nAN8sgjf518ACxaRnH3jzouUBbEz++oddL65eruDWOCq0A CeVP715xke3PDwpL4OMkGXq/LVgv6bjqFHV/jfBAP/FkXh1IoL18lnEC5RGUealjE/O1 4EXsUl/Fosl2GY/xAZ6wJ/ef/uyDGJlVzCQYXt0gEq/uRYV+hYcDEArk60IaqGUKhjAQ KKJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=YTvB89BBnRi3Cx0EmMW59JPDQvoFJsorM7vMSRfLkyE=; b=pUW/AuAE4jA9m08hnGowe0Y9bGK6gHsmfTL6/NXlqInTvPa1xoL/3rqf3qC9HF0GvJ MwpoZKvMcyqgpNtjXQdMypFeMjWOygL80n+VC0BKStjIpYxIZW1cfk9hbbHr3O/S7wM0 If/QfdkNZwiEv6AoQoe/qkMV58R6KFyLEeytbv4cv56B7eJ8cyD3MIB4U8n+tK+q+KOa 7MJ1jcg17USa9WbGrV8fkdQOiPErKj7Xj8E52jPW/CJ0arAdm1FKAzisuGnPMhe5+n2N TIlKxKJass36zxbb1BJcfzmoVGq8ACo7GLD/+NAmSEpgNQCbB0o/ZB14YPi216fZKtf/ wDGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jmEBauen; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g186si213734pgc.320.2019.02.04.07.01.39; Mon, 04 Feb 2019 07:01:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jmEBauen; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731014AbfBDO5a (ORCPT + 99 others); Mon, 4 Feb 2019 09:57:30 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34592 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727217AbfBDO5a (ORCPT ); Mon, 4 Feb 2019 09:57:30 -0500 Received: by mail-pl1-f194.google.com with SMTP id w4so54190plz.1; Mon, 04 Feb 2019 06:57:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=YTvB89BBnRi3Cx0EmMW59JPDQvoFJsorM7vMSRfLkyE=; b=jmEBauenEcxlTGwThmMUdcs/6pqqu2P6X9R/717hUTz0zsO7UrKnwgraQh3BI38C+j qMkIjtGQCyiqtm1sZ9AC5lpwMUKw0KlbUMbSJjtpyZfE+qcU6l5b+cyyp7A72vLbuwua lkNLwxY7/dODdBw6k1WRhMum9lxlXEP9T2pthL6ieDc+scJk0Xyzehk6mleEd0IdONzS yGedM1MhUwm80xtZylYXYbU5oKjFjGQr6QKGdwqwcYNAko2WuiEAyvXjrsikVdkh9jjd tcavkTbXqoZ9DeCTdPRQuIShhDP99i8gDZAqTpYyANgYB7NI0lORNraAaaGIyrcomqZ2 lDBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=YTvB89BBnRi3Cx0EmMW59JPDQvoFJsorM7vMSRfLkyE=; b=rioSmMUC7auCtC5h++L84qLXwsikvLFGuf+ZugY8qw9NGSrKhN9TkfG6cRVSu/91iV P263PM8GuHaLxA3pbjGt38LN40bSvaOnkInfZAPPyh83VO4UTzjUdgIbn0xjXJhFQAQ5 PQdqjMtz3JT/pXNYUwTzEInfn4BPjbgCuaoCQfbrBue1ygSyskOObHl1d5SnnBQFIHGs UyzAb6gq23KbEfaiU1rcVkB+hmuDHUWEfdtK/T36/EleZ6hv3J80mWPaRZXQzemOunrl gW1sNsXXsxjtgxK65krGl3yn5FAhRPwlaa2txUy319s3bJt8Lkl+hXXFlvV1FzOZJAIX FpEA== X-Gm-Message-State: AHQUAua1NWtILCk1Cm97Vpw7zL9yy1/A7MYpJcfM3zlIMx2kr6NrXO4m zqqrGoMHkebfvyfretLCE1byKUwi X-Received: by 2002:a17:902:b581:: with SMTP id a1mr7712768pls.36.1549292249179; Mon, 04 Feb 2019 06:57:29 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.176]) by smtp.gmail.com with ESMTPSA id g2sm366423pfi.95.2019.02.04.06.57.27 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Feb 2019 06:57:27 -0800 (PST) Date: Mon, 4 Feb 2019 20:31:43 +0530 From: Souptick Joarder To: pawel@osciak.com, m.szyprowski@samsung.com, kyungmin.park@samsung.com, mchehab@kernel.org, nicolas@ndufresne.ca Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCHv2] media: videobuf2: Return error after allocation failure Message-ID: <20190204150142.GA3900@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no point to continuing assignment after memory allocation failed, rather throw error immediately. Signed-off-by: Souptick Joarder --- v1 -> v2: Corrected typo in change log. drivers/media/common/videobuf2/videobuf2-vmalloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-vmalloc.c b/drivers/media/common/videobuf2/videobuf2-vmalloc.c index 6dfbd5b..d3f71e2 100644 --- a/drivers/media/common/videobuf2/videobuf2-vmalloc.c +++ b/drivers/media/common/videobuf2/videobuf2-vmalloc.c @@ -46,16 +46,16 @@ static void *vb2_vmalloc_alloc(struct device *dev, unsigned long attrs, buf->size = size; buf->vaddr = vmalloc_user(buf->size); - buf->dma_dir = dma_dir; - buf->handler.refcount = &buf->refcount; - buf->handler.put = vb2_vmalloc_put; - buf->handler.arg = buf; if (!buf->vaddr) { pr_debug("vmalloc of size %ld failed\n", buf->size); kfree(buf); return ERR_PTR(-ENOMEM); } + buf->dma_dir = dma_dir; + buf->handler.refcount = &buf->refcount; + buf->handler.put = vb2_vmalloc_put; + buf->handler.arg = buf; refcount_set(&buf->refcount, 1); return buf; -- 1.9.1