From patchwork Tue Nov 6 11:21:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10670133 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A23015E9 for ; Tue, 6 Nov 2018 11:21:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09AF82A009 for ; Tue, 6 Nov 2018 11:21:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF3EE2A0F5; Tue, 6 Nov 2018 11:21:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89B092A009 for ; Tue, 6 Nov 2018 11:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729373AbeKFUqQ (ORCPT ); Tue, 6 Nov 2018 15:46:16 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:33952 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbeKFUqQ (ORCPT ); Tue, 6 Nov 2018 15:46:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LcsTEgZAeWAcrt29heYpPNLSblXg16GlPPcPdOLss2A=; b=VlcIs3QcK7N0YgINnjvTJksZn 4fqh0WBs/M7UIH05vGjtlFnwquAGWIilwEqTDyxjEKz5bFSYZQumGOOyAc3Pz9QQwNE5dNuRvsvGB Fc9qL3rgT8ak/wtVRh9A+pLUz1cAtoLZrhHZ7oBgViJlkFI8ro7Y7AWZe7JU684cdQM09FTX0CZOR vLIuehzK0mP+MTRPWU2lb611HvYVH8ohST0otbBw3BWpiOW0NCErOPZgQJFU5OCYd0pD2LGl9unXC NF6EKflt6XJZAVy0sNxCzlJ7+ku2XbvHI3kv8cIMHAE9oPQ/JlSlIo+l7nyj626exfxZLdXvh8KdS 9a45KKANQ==; Received: from [191.33.155.146] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJzQK-0001MZ-NN; Tue, 06 Nov 2018 11:21:32 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.91) (envelope-from ) id 1gJzQI-000A1j-8y; Tue, 06 Nov 2018 06:21:30 -0500 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Maxime Ripard , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] cedrus: check if kzalloc() fails Date: Tue, 6 Nov 2018 06:21:29 -0500 Message-Id: X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As warned by static code analizer checkers: drivers/staging/media/sunxi/cedrus/cedrus.c: drivers/staging/media/sunxi/cedrus/cedrus.c:93 cedrus_init_ctrls() error: potential null dereference 'ctx->ctrls'. (kzalloc returns null) The problem is that it assumes that kzalloc() will always succeed. Signed-off-by: Mauro Carvalho Chehab Acked-by: Maxime Ripard --- drivers/staging/media/sunxi/cedrus/cedrus.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index dd121f66fa2d..6a73a7841303 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -72,6 +72,8 @@ static int cedrus_init_ctrls(struct cedrus_dev *dev, struct cedrus_ctx *ctx) ctrl_size = sizeof(ctrl) * CEDRUS_CONTROLS_COUNT + 1; ctx->ctrls = kzalloc(ctrl_size, GFP_KERNEL); + if (!ctx->ctrls) + return -ENOMEM; memset(ctx->ctrls, 0, ctrl_size); for (i = 0; i < CEDRUS_CONTROLS_COUNT; i++) {