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: 10717983 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 0A821109C for ; Fri, 7 Dec 2018 11:13:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC9EA2A679 for ; Fri, 7 Dec 2018 11:13:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D93172A5FA; Fri, 7 Dec 2018 11:13:53 +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 817F52A5FA for ; Fri, 7 Dec 2018 11:13:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726047AbeLGLNw (ORCPT ); Fri, 7 Dec 2018 06:13:52 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:47354 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbeLGLNw (ORCPT ); Fri, 7 Dec 2018 06:13:52 -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=bN5YLJGy9YAmuQQ8atOsp/1gnpm8kDXFQUDcL2uVBX0=; b=Z2IItIAhWKEqjwh7C6ZjT+yGt Qznglf2pj6bDfOiD5K0qRtT1UDtjtQ9IMuyY/DGN0+60DiBAFztRcJ/D6ErOw7o8klMd01PZwqJrg 1ixP7hT5+Mix6EK4QyrrKkA2vaBuVUiM1w1+WS/9QM1xvx1vG3D2pKm6Yu1xoAgH51IR4dtYkZ0fX iCkmQbTP1gjGnUBO6SrIYaFyBWszoYuBoqBChmDZtd5Sy4A0h3aytdYXBnKT/rVHupx7pEMcsY3ph MpXleeLsjeGchUa9q4Ia4I8rj5Y8y05P520MdzXgat2HBlRn+KfXjEhkgLo2XCYEMAB7kPLUAoZjp nI97KLINg==; 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 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] 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 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 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 };