Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp490854ybl; Wed, 4 Dec 2019 06:13:06 -0800 (PST) X-Google-Smtp-Source: APXvYqzV/xlSEDSLP4+UqDNAC6DXIaKAJjutwxu4164VYAJmRfg70RlLIMrkR4dcSeAzaUFkV+24 X-Received: by 2002:a9d:4c08:: with SMTP id l8mr2549326otf.360.1575468786474; Wed, 04 Dec 2019 06:13:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575468786; cv=none; d=google.com; s=arc-20160816; b=zlD4rExfPFByxXp9j5IrzkgVVL7s+5jFOpscPrm5dXWZDUtpIcL3p4G8Qv8m5cRfpM X305mDJhjC82vuBKZP2MstnyRKEjIa5NbG5nHIRd7dmYHI7uYSCZQovSy8FlQfHAHez4 y1o9C4Wq/0LuNzs4iojyY/YVFMli1OzBu9bExuYSGlY8WFHiYcZMUZGmztfxyPlO5cAU 0IPTTmnecG+dTqsx7rjHAmNRQ9OVNFWplsx00SouJHh9aEuNGxPItFCAZVtdD9TNrSRX WYjZ4M2m2y91ETCDDI4rlogOHw1SkgoKcON2tE/2Vp0EhZoQUjqZbDfl49Idl2esnYry 8BEA== 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:mime-version :message-id:date:subject:cc:to:from; bh=pRvjErChW7M+ZreVGydoZdKBMOhkCu6GVbndJwQhouE=; b=E/Tq5rSEC27r8icu05AtUVf5lsiwABZTKwH2febKDvbBKpeesq8XUNczICMmL2FQ/s N0ojKZv0wzTEqu6R0cXVkGlfaIfJulXJiSu5OreBfBvaOuwck+J2ro/aHjNEJl7WLqze 8z3ahU+NE3BZbYecCW+KaMZv3DMGdnMnoZShqd8L902JeuL2/gkvLZGvq76O8HghthAN 0jDNJRPo6bv3QtQ0EN3vzHMJ/yscZrVe+aIu8uBZnroO/zObQ8PmxyoK7l7qW2McXa5u ddjjVs73bM2IanDs1G6ZmHVRThV7wBnRUNp8JqP+N2+q9E/8UpDc8aKolOLBO+VlLNW3 mj+w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12si3279837otk.323.2019.12.04.06.12.51; Wed, 04 Dec 2019 06:13:06 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727948AbfLDOMF (ORCPT + 99 others); Wed, 4 Dec 2019 09:12:05 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:57704 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727828AbfLDOME (ORCPT ); Wed, 4 Dec 2019 09:12:04 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1icVNn-0002Ao-Sz; Wed, 04 Dec 2019 14:11:59 +0000 From: Colin King To: Maxime Jourdan , Mauro Carvalho Chehab , Greg Kroah-Hartman , Kevin Hilman , Hans Verkuil , linux-media@vger.kernel.org, linux-amlogic@lists.infradead.org, devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: meson: add missing allocation failure check on new_buf Date: Wed, 4 Dec 2019 14:11:59 +0000 Message-Id: <20191204141159.1432387-1-colin.king@canonical.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Currently if the allocation of new_buf fails then a null pointer dereference occurs when assiging new_buf->vb. Avoid this by returning early on a memory allocation failure as there is not much more can be done at this point. Addresses-Coverity: ("Dereference null return") Fixes: 3e7f51bd9607 ("media: meson: add v4l2 m2m video decoder driver") Signed-off-by: Colin Ian King --- drivers/staging/media/meson/vdec/vdec.c | 2 ++ 1 file changed, 2 insertions(+) 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; mutex_lock(&sess->bufs_recycle_lock); -- 2.24.0