Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1201918imc; Mon, 11 Mar 2019 08:33:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxp+vZDsT8ebdtKhdHpt9lVA+Pz2t7Nc12uI7bMpc5sd6xIPB68IDXK4DH4AlLLLJGzKQOB X-Received: by 2002:aa7:8005:: with SMTP id j5mr33486425pfi.211.1552318400047; Mon, 11 Mar 2019 08:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552318400; cv=none; d=google.com; s=arc-20160816; b=StZO5DF2R2buf/Go1vYyymQO1gAdjDDFcaH/CpMQHeedZp25oqxvsqb5JHLGX6L3TO HFNhekZ5U+fQHCcafBESYF6wFM/n0xWGgcf8Gf9sTaO2QhCByVclyGZjE6x8zKWs8j3O Dg0ysY5V6LEymzvFNFDrBVP+LHP9enTK84Rw8xW1FmW6GYi2B5pUDDguvh5/KC62gicu fFLbkANhXh5tri8gAXJTucXYaJwvPr69OSeYpwRCr50+L2K5OpzAyVMb+GY3FAOMu8BN Y0CZx4N8+U/c7B/iDP4P+QJoHOYWT11Qo033Glt3GvQKdrsBrb5vW4gFXF+X9q1pCgQw +Teg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=EQp296CCJHJi73tm7U0Fpj4NvT79CDYo+sJDL+q9Q7o=; b=USektZ4PwnOjpGE43+8liljQIfX+Z3yxYkushymc90C81/V5PhuUvFHhi5PNvLV65l dRAA0eNtgTvp7TNmoKBjJNUtpijyqlfOV3vFFJINL6pV1WnYLL/WD66eqah35huLvg/+ PwG/IvXt8/FxvQAjdkBTZSs9cunMnizRR66coxOiRav1yg7qlst5oPoKszPjHCEmYePF pFxDFGnBSL0VmmE+u4pehhQ0fwg4LRqKq6uKUrZiLUte6wWga0uMTFkbY708VFNFexLi fFF5GNcsqdWoqtMv5msAmoOfujQ27yJysL4uL+CZW/nlh5iec7zX6+dI8B8GolKc6f26 CT5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KMw4kyxb; 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 c3si5911839pld.178.2019.03.11.08.33.03; Mon, 11 Mar 2019 08:33:20 -0700 (PDT) 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=KMw4kyxb; 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 S1727492AbfCKPbX (ORCPT + 99 others); Mon, 11 Mar 2019 11:31:23 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46899 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727027AbfCKPbX (ORCPT ); Mon, 11 Mar 2019 11:31:23 -0400 Received: by mail-lj1-f195.google.com with SMTP id v16so4451704ljg.13; Mon, 11 Mar 2019 08:31:22 -0700 (PDT) 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; bh=EQp296CCJHJi73tm7U0Fpj4NvT79CDYo+sJDL+q9Q7o=; b=KMw4kyxb/nokVc8caAJdAo7nkfOwjCVD+vD8Cno7Fjgnrkt16OmDDTTkH5TJ6B2gRQ yzrOl2S3V4rR8cf1C1kWnctRBxbqHuCQt+RujDVJBRaE6DtVejqYrwedX3vpKzvTWnsR HvGB66t3MCE9TF0MJSituMChFJQlyBB5UZW1nQLEagbp9ddd6Lor6k6QKrTSKacKNYcJ HC41DnkVGXXdhA5Z2AQTYjjAKSE4DDAbVVkFli+qPeS8syvp0wbANJTaAAc3sgZmp35f +pW+2Z0lJ8Vm5vO/d3ib9VMmVLrQsw5i4sXRu2/LtcCWZsawddsEvNXB4vWL6EEYySks hyMg== 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; bh=EQp296CCJHJi73tm7U0Fpj4NvT79CDYo+sJDL+q9Q7o=; b=kobBMSZCK+/6TeiK52ERhyKsZ1DXLvzJ9Q8a2d0EibS4WF9Z1wIHB3QoqPDRC1Web1 oxbAUMU/xoWGfU9ex+0IcceCIFKg6dFWKLikurqswe+gOh7SdO96MIajYoBBtNNw8iQh 3zPOTA0P5bxVtzYuY1Uvdznr5XrFTLRoMYxwJvJ2FS1u3H+9S13Fh13CUehE3ysg7oUC M7t/o7R3fFlKK2mjSsXdCu+B1r4LOcqYRxZJXnvJxAQjk4PM/AHL39SMRLwag/6sk0th vGOJo30OB3HSTwliDmfDhCI1DaqH8cF/ZnW1mHFjvWcXWBLyKeINDaj3Np7nmZaCb3i+ bVFQ== X-Gm-Message-State: APjAAAXNgJ73cjeZpOuchpiuRB78kXW+bxCPPd3DJSzp6Q4bWv1U3juW FZQuD+RPg5huOczFElYr+ScRH4OxXX/39uhGEpQ= X-Received: by 2002:a2e:9b95:: with SMTP id z21mr9056336lji.155.1552318281137; Mon, 11 Mar 2019 08:31:21 -0700 (PDT) MIME-Version: 1.0 References: <20190204150142.GA3900@jordon-HP-15-Notebook-PC> <52354072-81c5-4aaa-b3ea-885437e043b0@xs4all.nl> In-Reply-To: <52354072-81c5-4aaa-b3ea-885437e043b0@xs4all.nl> From: Souptick Joarder Date: Mon, 11 Mar 2019 21:01:09 +0530 Message-ID: Subject: Re: [PATCHv2] media: videobuf2: Return error after allocation failure To: Hans Verkuil Cc: pawel@osciak.com, Marek Szyprowski , Kyungmin Park , mchehab@kernel.org, Nicolas Dufresne , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 11, 2019 at 9:00 PM Hans Verkuil wrote: > > On 3/1/19 4:04 AM, Souptick Joarder wrote: > > On Mon, Feb 11, 2019 at 7:42 AM Souptick Joarder wrote: > >> > >> On Mon, Feb 4, 2019 at 8:27 PM Souptick Joarder wrote: > >>> > >>> There is no point to continuing assignment after memory allocation > >>> failed, rather throw error immediately. > >>> > >>> Signed-off-by: Souptick Joarder > >> > >> Any comment on this patch ? > > > > If no further comment, can we get this patch in queue for 5.1 ? > > 5.1 was too late, but it will certainly go into 5.2. Thanks. > > Regards, > > Hans > > >> > >>> --- > >>> 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 > >>> >