Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp2717877ima; Sun, 3 Feb 2019 05:32:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IaG4B+pmKynBgeDoh2M0ANSWvsmo8LiAYUKzy++XDcq1a3iDAKjDE30xrAhCfAfo+3aTWmC X-Received: by 2002:a63:91c1:: with SMTP id l184mr9571598pge.29.1549200767859; Sun, 03 Feb 2019 05:32:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549200767; cv=none; d=google.com; s=arc-20160816; b=tHMKImUg6BBSy7WYsmOZFUJy4grTG23PR0+Sp6Y2+WsO5PHc4lWTTME/bvJECUNUgh Wr8KZ5MzDVOmzofs+23xOvAl8kho+ynzurUEGDg3b0XgBjCga2zW8xlbOMEKNaiYtFcf oosUwNTckpV3DCRKslm6s5bIPty2fjTva6idKjzlWRC+yefhXtN/Fn/H1wMVhBJ2WJyg Q5c0quyHLL1GdRkvGBpoEyknJd5uvAUuLE0O2iMoDRxTHSxX7aXkCv13h/B1GruRHvPr K3SNoM6VtgeywP7d3nu73KwLDmCWhoZjszl4mV9O7V1gRNt3wU+lTKh5SJ068dvNMSvA YBrg== 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=84hrRz7nOiZ4YsaH604mLPJ8wBSVpD84s9+8PgQMBhg=; b=NN71Hgjh//d5wV8aUZ0ReqPkI22WRhU0MUZJ7nFVwUTA1DsOKCXk8KOwak/P/a2WK/ NafTLWGRafCNJLGgYIGEZUBo5aUrnXCz1eedTtGGKBMF3dLqYnXwF7s00QvVE7PRRO3Z mmEMSK2xUsVC+oqx6Ln4yVIzlT6nW8KIhwZA8bVxhKpmGiY+pf2d/5/vcL3onFsB8aaD cyD6rBDwF6ZnCSnNln/9jOcqDGPm3PSmHUwVTBAYzh8+9zTBMAi34sxrP52NCayOIfQ2 svyPfZQA+HEI1ZczGQe/mnM+bGv2FVTHYYwQ6+kx2GWjRZhb9g5A/Zqyk8a/TXaNCARh fGLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fbXu2AT2; 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 d40si12943799pla.427.2019.02.03.05.31.59; Sun, 03 Feb 2019 05:32:47 -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=fbXu2AT2; 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 S1726821AbfBCNb4 (ORCPT + 99 others); Sun, 3 Feb 2019 08:31:56 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:36950 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726582AbfBCNbz (ORCPT ); Sun, 3 Feb 2019 08:31:55 -0500 Received: by mail-pf1-f196.google.com with SMTP id y126so5538624pfb.4; Sun, 03 Feb 2019 05:31:55 -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=84hrRz7nOiZ4YsaH604mLPJ8wBSVpD84s9+8PgQMBhg=; b=fbXu2AT2aPrW1Y5IKPdJ9et9x+Ald20wF+zSsCVPz9MK+j20snS9qSMbTF6kVmBLzy QT7+6Y0YVlpRlCSeLnlyrS5lWQS7SPdKMR8oh4wbG0Y9gu/uNu5WFV6iQeXMXmTIrjKl vFwCdAvO99HoDXCNrZuLGwjRyzNjwk8VnnNPp5SOwqHPnfuFqsxxrLtITPljx4+smtyX nVUpXOGAs7MMIhHKw/0NB45Kh+MOetqRbfc5iAmnCBXUUkk0l2vMXnVcKrDhlwKCupua A5BJZfSAygelyiN2spJGJrdH7DFP7I1gM1CuRMJtD4/yrhGRyu5y6nz3BDnDef/Zahzp BMKQ== 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=84hrRz7nOiZ4YsaH604mLPJ8wBSVpD84s9+8PgQMBhg=; b=kWW580ZZ0h6INAEMo84kObRKKPqGlYEN2+Mj5z6+LuBO1/fFhjOvpD9sDp517fJErK LgVFBc+7YyNA2l7rOypWBdsU2Upx8KPiAMFXod2PYaA/Kwszm62A2vz/eR786wu5G723 Z1Y6X/BYeZdSYrG+f7l2kObP3euXY3Q3LoIzpECWsZ3mx+UZkXh72nyXeG0I40zec1dl Skni5dOL4s/EGeNyTYqOSR4LVIIjVA0FIYDA+vJtFCAAcexUXTs08+8TBB4UwPa0LsyM 7F+0f9z5IPGUF35/Ti778baS9D/+Y44TaXKF+8ErbyA4dc3XAuBnKhhUBBVPadIvvLDV xfMA== X-Gm-Message-State: AJcUukdAlEE2zYL1C3IjbVKmVQKOsCytqqWbBLLCe/VMQpSpyHqnZulH WBLSi/j/7z4rKzhihE9+1io= X-Received: by 2002:a63:6a05:: with SMTP id f5mr42242966pgc.72.1549200715054; Sun, 03 Feb 2019 05:31:55 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.176]) by smtp.gmail.com with ESMTPSA id 24sm71166558pfl.32.2019.02.03.05.31.53 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 03 Feb 2019 05:31:53 -0800 (PST) Date: Sun, 3 Feb 2019 19:06:08 +0530 From: Souptick Joarder To: pawel@osciak.com, m.szyprowski@samsung.com, kyungmin.park@samsung.com, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, sabyasachi.linux@gmail.com, brajeswar.linux@gmail.com Subject: [PATCH] media: videobuf2: Return error after allocation failure Message-ID: <20190203133608.GA26010@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 assignemnt after memory allocation failed, rather throw error immediately. Signed-off-by: Souptick Joarder --- 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