Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp525068ybl; Thu, 12 Dec 2019 23:48:40 -0800 (PST) X-Google-Smtp-Source: APXvYqw49bp2BTuWkpvkFTXVmyT5GOqH0I56GIJjnIXf7c3IModkDn6hgIfHwpA9CDq+UGY/QJzF X-Received: by 2002:a9d:2f0:: with SMTP id 103mr13471079otl.218.1576223320306; Thu, 12 Dec 2019 23:48:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576223320; cv=none; d=google.com; s=arc-20160816; b=CXNCQ82JHyeH7ezAksJmiThptanU9sIzTlvLnzhfHj56jHhaoHKGhwOI7bi+QPR1h2 LjEJhlzbPOLKGIZ34RBFZGLnQfb1Y12jM65cUdpbdmRWM0Sui9xFPv0sUpszgl1Wnz13 kqGZ/yb8NPLyxDOARaULpnGhwIYlGKt5MIYTbg+S7KNkOfO24lYoyWd6X+mpioMBSmwQ hJSRic65IZmDyRR/YGzFLumWN6THLLUhtvsu6f1h+S83ZZFpFtXFYXr9W8M60ZTjaIdU DlPLRzN+zWXhJnzGfyCPf4zlWBKnOn8lJBqCasqvPuEkFW6DIOit3Y9o1527fYLV1xdw 3Ljw== 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=vTSxvUqfa6FoEiQTgKaCRKQ961VVqjF3zVcNDPTqeUQ=; b=OQon+Wyxg0uaeRmCBOvWuurkTKmTzfwFWXHuYeWwpyrVuz8xGa53pJz3oCWMtOX0G8 cgK4mI7qzOMW5kmf1NVi11l5GLwrc3Om/jujsVlw+8bT42rhFiH4Z1v0xS12dVJ4FeJO is8jjoa74r5T3O3FTuW4+NzSqm6tXADXyf+j+nTvrOBVGZhdWcs4BHYvR+zgBA0LW1mS ikojVM5YNa7o4eGWH2YvKLBOhlTqavMitmpG78+QK1iQ6+zz0St2rTKTEuV8nqmepkhB qBKf8MGMn0frGeTkv3kgdhYJCT+9HLxsqi71WZL53OtvD/BlmphLxdzsWj8X1LR9Hf29 zuoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=FygEFXPk; 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 h11si5087676otr.197.2019.12.12.23.48.27; Thu, 12 Dec 2019 23:48:40 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=FygEFXPk; 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 S1725946AbfLMHrj (ORCPT + 99 others); Fri, 13 Dec 2019 02:47:39 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36830 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbfLMHrj (ORCPT ); Fri, 13 Dec 2019 02:47:39 -0500 Received: by mail-wm1-f67.google.com with SMTP id p17so5476711wma.1 for ; Thu, 12 Dec 2019 23:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vTSxvUqfa6FoEiQTgKaCRKQ961VVqjF3zVcNDPTqeUQ=; b=FygEFXPkvDTEqQFNc95GmEPQFaOALol3FJZVABII8mgatRtgdG31UxBB+q2f85tioV YaDq76YgKg19kavCxLDGCXYdqM9e4pt1+h8vMM1af+h493sGTqtu8x0x0Y7pDZ9rZODl D0Tmu44OHSSAi7XTfiw3ezo4lLtG/fvqKXr9UP1I7ioXEwEcTuWWl+MwWhGJYbEnMq+w ALx7B4du4u7jUwnaaQoo9t+S3X/fO96NeqeTQ28Ffuy5wSsYUMg78UyAtuMEUmLPhSNZ lUUoOAhyKE5fSjw0CUYEi+vy/hxr1Eua69Uhw+w3KzjGJP3OD8JUBE+JCzVqCd/mRebH 8ZnQ== 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=vTSxvUqfa6FoEiQTgKaCRKQ961VVqjF3zVcNDPTqeUQ=; b=q5FGEKOhJPe8PqT638iUJNimqoMVvF1Z6gzviu4dwLUcjNsce9rHg5GS5obivplELS yRHrVC0U+3sZ94pH60KjZo7DecVjziTD/RZXH8Nz+HsWcw5LtpazcxcOrFI7uAkv3AAU ySKAWtCJEJjLC44qMirCLSt/P5r49Wv7vNbKeRzy325jU65l7zFuDa3D3jYs6EgPPyX/ fPOEwpgqHzpohQmyyVbr27uX/hW3WETCIT6W/ZBEEg0wKV5O/xVBeSDPelGn4OfDkXjV 8DebeuUFyfkVcsGlsR7VmlDl4RaKBrH9eDUz+feEeusgfwvI5prqrkv/OBuURFCERjlB 29NQ== X-Gm-Message-State: APjAAAXVOu6GA56Eh7JR4lNedV1DBSQ2XPYzyMwTjrN7WlLdoz39xN4T bjikJu6/tP8juor+BT6MGsaPUmZN5LdBqHdi8Me+8Q== X-Received: by 2002:a7b:cd84:: with SMTP id y4mr1059323wmj.57.1576223256882; Thu, 12 Dec 2019 23:47:36 -0800 (PST) MIME-Version: 1.0 References: <20191204141159.1432387-1-colin.king@canonical.com> <20191205080611.GY93017@google.com> In-Reply-To: <20191205080611.GY93017@google.com> From: Maxime Jourdan Date: Fri, 13 Dec 2019 08:47:26 +0100 Message-ID: Subject: Re: [PATCH] media: meson: add missing allocation failure check on new_buf To: Sergey Senozhatsky Cc: Colin King , Mauro Carvalho Chehab , Greg Kroah-Hartman , Kevin Hilman , Hans Verkuil , Linux Media Mailing List , linux-amlogic@lists.infradead.org, devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org, kernel-janitors@vger.kernel.org, Linux Kernel Mailing List 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 Thu, Dec 5, 2019 at 9:06 AM Sergey Senozhatsky wrote: > > On (19/12/04 14:11), Colin King wrote: > [..] > > diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c > > index 0a1a04fd5d13..8dd1396909d7 100644 > > --- a/drivers/staging/media/meson/vdec/vdec.c > > +++ b/drivers/staging/media/meson/vdec/vdec.c > > @@ -133,6 +133,8 @@ vdec_queue_recycle(struct amvdec_session *sess, struct vb2_buffer *vb) > > struct amvdec_buffer *new_buf; > > > > new_buf = kmalloc(sizeof(*new_buf), GFP_KERNEL); > > + if (!new_buf) > > + return; > > new_buf->vb = vb; Thanks for the patch Colin. > > So the buffer is not getting recycled? IOW is leaked? > > -ss The "recycle" mechanism in the meson vdec is a way to tell the firmware that "hey, both userspace and kernel are done using this buffer, you can start using it again". Not queuing it for recycling means that the firmware won't use this buffer again, it's not desirable of course, but if there is no memory left to allocate a simple list element then there are bigger problems at hand. Either way, failing this allocation and returning instantly doesn't leak anything or do any damage kernel-side.