Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1200968imc; Mon, 11 Mar 2019 08:32:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3vKtap7vciMZ5rIBRbjgg3ot0umVNtyrLlLdJBwpKaKj8J/Aazeua3hDrTFai3n2wPT3N X-Received: by 2002:a17:902:e40a:: with SMTP id ci10mr11069790plb.77.1552318332138; Mon, 11 Mar 2019 08:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552318332; cv=none; d=google.com; s=arc-20160816; b=uvs7GH0zVZyy1ugFd3qR1y93CFZCLjwphY+XcAWcjHsxkT39AZ7JRoe4izRUnFkcl7 oD79SMF0cz4Km1Sa/Bxmd7DkqlDIxUiJeHCQWMAIEOvnGd/YBoeCar2yZ34wdIE49Izh z4CWLtQgT7+LHdDs8/FLVJFE0sjtnBRtx4d2RN+8M41X8+2lAcCAOWtEP2nYAWtpqLEi 5do53039p102zo9CU/ERT5IEvVr9506R6igsN9tnAz+S/jcz8H7N2sp4HmQrCINu2VYX fucPT4LiV2//yZ0GyB1T55U/Hk7wZwBSZEc3XPMZInEqL14AE4La9FjPi6oTQEHfDlir q6QA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=yxtBHPs7qtTzmihJ3hNJ7mdNmD9RmiV+844sfnIOJRw=; b=ZVWv3rxtK/qXbGkd7mJvW+2Qnehri0hZ5YZ0sqhszJYV2YMqvRrvgqn77BEVfpZhxV jiQMdg4SfkEYdzvtXeqHtTZGW0p8CbFSIuQIn364MCzxjzXtMzhp/be0ZhKEj2HrtkX4 BMlCHKXoh3wOjNhpB/BsDacOsGjtU9FNoFHFqD7OjeZ5q8XfYuvyaN915ZAOJIHIhrG8 OznmHIQGbjKUUqSq/DKefFeUmZz9Ut0sbHrML6rDh68T7Nf2+wUOh1SWhgOZ8YYWDYww DAJVSdHNNTPKXA4S15uP4SSkOMfSIrRHrQdgSIpmhSwqClWAg5TJR1fojpKYcG9RMQS2 BVmA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d195si2757318pga.309.2019.03.11.08.31.55; Mon, 11 Mar 2019 08:32:12 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727210AbfCKPaK (ORCPT + 99 others); Mon, 11 Mar 2019 11:30:10 -0400 Received: from lb3-smtp-cloud8.xs4all.net ([194.109.24.29]:51736 "EHLO lb3-smtp-cloud8.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726864AbfCKPaK (ORCPT ); Mon, 11 Mar 2019 11:30:10 -0400 Received: from [192.168.2.10] ([212.251.195.8]) by smtp-cloud8.xs4all.net with ESMTPA id 3MsOhSh7T4HFn3MsShFLa8; Mon, 11 Mar 2019 16:30:08 +0100 Subject: Re: [PATCHv2] media: videobuf2: Return error after allocation failure To: Souptick Joarder , pawel@osciak.com, Marek Szyprowski , Kyungmin Park , mchehab@kernel.org, Nicolas Dufresne Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190204150142.GA3900@jordon-HP-15-Notebook-PC> From: Hans Verkuil Message-ID: <52354072-81c5-4aaa-b3ea-885437e043b0@xs4all.nl> Date: Mon, 11 Mar 2019 16:30:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfGLeZguZ64odaxVEpPch/aqvhe+xCcl3r3ThkmH7WUtHafMk/cSMbyLeOu3TAgK3qDGMZBtoon5u5D3XK2Cza/o+3TQymjY9nWE5pVUxr1OHNPOvp+8S RAznPS8eQN8UWMTI4q3cGWIm+LQQEahfceRjxl6CAfuzaNai8pSxzVoTf5ys+lPgoARU31JVsEQxIY54mRGQO2gmi9vc47ODy9gCkh8NQ+x87EJdyIGihDPr +xLcABRQ7KDXTd9q7MHA8JC8YGQHUUqP3GMHrvGFBLvSpjy1Yc7rVQKSdbjyuDgo8M+Hh25sm0io0CFvNsMP0IxoxIutDHfivjJUYoKryGfHkPjlc8wz9aFm kSLjj2nGBWy4mVeI5bNqGAzdnx1pyrq0RCqTx3rLsacpLHnWGEPqZL/9G/GLtJCvkuPN6tWj Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 >>>