Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3272402ima; Sun, 3 Feb 2019 18:05:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IaZbxE+oBagPz4I4mNC6b6wQT/gRpy1RejQielr/3T+t8uxwafS9gvZtUQ7BOFX0p8/SlSU X-Received: by 2002:a65:6684:: with SMTP id b4mr11341811pgw.55.1549245933640; Sun, 03 Feb 2019 18:05:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549245933; cv=none; d=google.com; s=arc-20160816; b=EOYPZ3/8LAShJ08Uya8IZg+C8miWsJ/pstmFN2dQ3dHtF1ahwCX4s3wWxCe/wVPe7z X2NYg3W95F3i2i1hNZo+tFbw2VaPMf84MzrnubN0u/fRjdtlEc/1u9Cm0KeGxjCw58s/ Y6VcGg938wIpZ0/+sdJfoi/jn8XRYPY/1S2udD1NG5+iCy5Oiec4eciLJQEd46N+pLCI u54YjDYTufIlJ81qAz0RRmCtL0sWGqJ6YztQ/UWZvUKsNKBKKxOOunSattMMjTg7F3VX l6I3uLI+UbBO4Q1E63HwuJJTfhev7DXMe9B3ImtLvBMI4TM1G2EjYifxMVVVNrmi6lGC KwRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Gncej+KcUYuYj1aFvSCSQuzMHP7ZhTohfMMS6cAUBGE=; b=BxeaE2xoR1NJWAKZFLnTAbGtWLFoQHQEHCeNjn/snJSTJoSUSQp7N3vOzAuNZBT+c7 W2Nhm492tTmhl74Z6dplEXht/N0UrnMh9FIpOp/ta3PALjc+zeflrHoJXOrrlVSch4gf eJLcob7RAboZtGVGan2SJBLrLlH4cxd0CSAhA+RM+S2lJt0GqTmAZOZUtiWO0E8yNHSE dg6bk2Q8vMEqIGMrk5Z4YzRJ67wHuqXJnPYlFgs9jLKHdvAfMs2BjkbkvwcwSUOxLM3Z EUjQp6tt4sM3mm2xAqXAXeG3x9wpE56scIMSbzvTKwVlmsYNI8sHb2/ftzjLiAxMCV/D FTkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ESoUPn4t; 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 q5si3302870pgb.245.2019.02.03.18.05.15; Sun, 03 Feb 2019 18:05:33 -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=ESoUPn4t; 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 S1727856AbfBDCDs (ORCPT + 99 others); Sun, 3 Feb 2019 21:03:48 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:38745 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727456AbfBDCDs (ORCPT ); Sun, 3 Feb 2019 21:03:48 -0500 Received: by mail-lj1-f195.google.com with SMTP id c19-v6so10284365lja.5; Sun, 03 Feb 2019 18:03:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Gncej+KcUYuYj1aFvSCSQuzMHP7ZhTohfMMS6cAUBGE=; b=ESoUPn4taaRm8lQk52gOmZYbr/rGaM6LeWHh4R44bV6qY6qjNYS+3naQLdps0GkOcZ C9QuvOwaklrgkmFQ9/I3EOAK7XXyuspK2THe/T3HdE7g5gjxf4V7I4dpQBNqqKGOH3Gq C+GpQEI5sbqQBqZe/UtECaBi6xODiI8ukv1eAcdVqhgKqlf+N63iPEvmBxrQqQXK+8xP bPSCmX0IyjZSJOFI/EQKKlok2CkSjn+1wMvh51Ev7dtJ0a5qvxsoRI98SHfxH0dp8OAl bxPpKErTamzGqlJ8RmWtzQpf8N6pq19bICxhwaZ/K083rmIwfhVSTEdIMLVKeitCSpe8 5zpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Gncej+KcUYuYj1aFvSCSQuzMHP7ZhTohfMMS6cAUBGE=; b=bFP2AYE18BTqxQsKo9eXLLsKTmNNdeQjpHJbUFmp7t9Utuj34JDg7203egZi6JIG2e TlmyKnvaUjuyprFbFaCJdDINb0ULaWlGgqm71TxD1WbsG/BzzcvX0a8msP3DWEAmvq5t qaFeXlR5dEAUh4HFIqnDsKZfXhI1qU9eO4zivUwdVpt7IDpJf8B1J2RiiEBfvvBv97ii xihggtJ4pMJOSpHp+ns54yGr6o6S6aG/2LZVK5LYGPms0/ZE2dFlmJ3UcPY3vSKzhHjD BKH7KrXLwVjOBDt3XhZ6eF+VmsTUnepcXe4gWZDVY2pXJ3R38nji4Qptb1AR1+IRqEZZ VfXQ== X-Gm-Message-State: AJcUukdfoKiADbiN+GcVlkjdC4yFYLDmLWtyCuluAjuzTOx4ljrq9+Gd ZVVekuxpCJjhrxiEIOEn4dKY0axY0PhssJrScHQ= X-Received: by 2002:a05:651c:14e:: with SMTP id c14mr39042574ljd.20.1549245825736; Sun, 03 Feb 2019 18:03:45 -0800 (PST) MIME-Version: 1.0 References: <20190203133608.GA26010@jordon-HP-15-Notebook-PC> <22f10cf289b8115fa9e60f89edc24ec2cf0f676d.camel@ndufresne.ca> In-Reply-To: <22f10cf289b8115fa9e60f89edc24ec2cf0f676d.camel@ndufresne.ca> From: Souptick Joarder Date: Mon, 4 Feb 2019 07:33:37 +0530 Message-ID: Subject: Re: [PATCH] media: videobuf2: Return error after allocation failure To: Nicolas Dufresne Cc: pawel@osciak.com, Marek Szyprowski , Kyungmin Park , mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Sabyasachi Gupta , Brajeswar Ghosh Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 4, 2019 at 3:25 AM Nicolas Dufresne wrot= e: > > Le dimanche 03 f=C3=A9vrier 2019 =C3=A0 19:06 +0530, Souptick Joarder a = =C3=A9crit : > > There is no point to continuing assignemnt after memory allocation > > assignemnt -> assignment. Ah, type. > > > 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/drive= rs/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 =3D size; > > buf->vaddr =3D vmalloc_user(buf->size); > > - buf->dma_dir =3D dma_dir; > > - buf->handler.refcount =3D &buf->refcount; > > - buf->handler.put =3D vb2_vmalloc_put; > > - buf->handler.arg =3D buf; > > > > if (!buf->vaddr) { > > pr_debug("vmalloc of size %ld failed\n", buf->size); > > kfree(buf); > > return ERR_PTR(-ENOMEM); > > } > > + buf->dma_dir =3D dma_dir; > > + buf->handler.refcount =3D &buf->refcount; > > + buf->handler.put =3D vb2_vmalloc_put; > > + buf->handler.arg =3D buf; > > > > refcount_set(&buf->refcount, 1); > > return buf; >