From patchwork Fri Dec 7 11:13:48 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: 10717987 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 5DAE5109C for ; Fri, 7 Dec 2018 11:13:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B7762A5FA for ; Fri, 7 Dec 2018 11:13:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F6A42AF15; Fri, 7 Dec 2018 11:13:56 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DA9072A5FA for ; Fri, 7 Dec 2018 11:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=NkYYyrjaFxqh3+Do0D0mimNkBDNVPM3tkscrDrLa3zs=; b=S8OUL2cMdzBd7Q Y6QWUNs1E8GyQCA5XdB7ulDJ2hVwhEfIcFR/hDjhVAdfN7g4PgdNBrAZLz3t++mNrGEMhjJm3sNvO PfRxCS5YpuK4h97FuUa9GLmM/j+n4SztZTRLQLbdCKudEsk1kd7+Y5Z06V/x07Oz1y/pdmNmAK5bx U7rodS12Sj0gbUO29BSpzExr+3H5kIkCTVED7J/GVvrdgo7GdW9JjeyhAsXicQUVnH1kclSpRYb6t tAo18liorYV9XtmKDY6kPTAREC9UL/+Ysg6GPEKJB6wDtljfmBw1Z6Suh2r7eSZBb3TdTZ+Y4u2qA v3X4eedre/UorGmOduAw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVE4u-0007iK-Lv; Fri, 07 Dec 2018 11:13:52 +0000 Received: from 201.86.173.17.dynamic.adsl.gvt.net.br ([201.86.173.17] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVE4t-0007iC-Lw; Fri, 07 Dec 2018 11:13:51 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.91) (envelope-from ) id 1gVE4r-0008UE-HA; Fri, 07 Dec 2018 06:13:49 -0500 From: Mauro Carvalho Chehab To: Subject: [PATCH] media: cetrus: return an error if alloc fails Date: Fri, 7 Dec 2018 06:13:48 -0500 Message-Id: <7d746ddf408ab1bc100d4d676daf3e2400637fbe.1544181226.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Maxime Ripard , Greg Kroah-Hartman , Mauro Carvalho Chehab , Paul Kocialkowski , Chen-Yu Tsai , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, Linux Media Mailing List Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP As warned by smatch: 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) While here, remove the memset(), as kzalloc() already zeroes the struct. Signed-off-by: Mauro Carvalho Chehab Acked-by: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/cedrus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index 44c45c687503..24b89cd2b692 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -72,7 +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); - memset(ctx->ctrls, 0, ctrl_size); + if (!ctx->ctrls) + return -ENOMEM; for (i = 0; i < CEDRUS_CONTROLS_COUNT; i++) { struct v4l2_ctrl_config cfg = { NULL };