From patchwork Fri Jun 9 19:27:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 9779137 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2DB4660318 for ; Fri, 9 Jun 2017 19:28:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B6522869F for ; Fri, 9 Jun 2017 19:28:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EA25286F8; Fri, 9 Jun 2017 19:28:19 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 B5FB52869F for ; Fri, 9 Jun 2017 19:28:18 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=zlWIScsyCEGhOI9sfSUhP6t3Dg8DlsBZL+zaX53CEZg=; b=beQ LHw2X1lbhogjqo4mc3stGclcOR3fDhBhotoAoUGD3Xa2mS6hnluXRPlHzofNOZpquwKE171J3rscw EV7mRDn/ubSF7QX4igCJPFVlbNQc15sgfU7q7up+xo5DwfTFSa+expP6W4VIYRQATZDZha99Yh8gL wNNItwrnTBc8aMCo9dEYmeRoj7YgHkClip6cCrT1LmTULRUf+sx4DdZmQVPGWtOKs72WhD6F7AqTL leQgCFMw5HYn/Sf2Yg1ZcECFIFK3AXWprTskKCQbdgU78jzXC2+qgHBY/vX1zS3M+qgqHybr7PT1/ Ga+S+eAUyE4DzfFHe9z4XeC+IYcLWDQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dJPZx-0005D1-N1; Fri, 09 Jun 2017 19:28:17 +0000 Received: from smtp12.smtpout.orange.fr ([80.12.242.134] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dJPZi-0004mJ-NF for linux-mediatek@lists.infradead.org; Fri, 09 Jun 2017 19:28:04 +0000 Received: from localhost.localdomain ([92.140.238.128]) by mwinf5d35 with ME id WjTH1v00E2muRsU03jTJ0v; Fri, 09 Jun 2017 21:27:29 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 09 Jun 2017 21:27:29 +0200 X-ME-IP: 92.140.238.128 From: Christophe JAILLET To: ck.hu@mediatek.com, p.zabel@pengutronix.de, airlied@linux.ie, matthias.bgg@gmail.com Subject: [PATCH] drm/mediatek: check for memory allocation failure Date: Fri, 9 Jun 2017 21:27:12 +0200 Message-Id: <20170609192712.18155-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170609_122803_066783_634C24E0 X-CRM114-Status: UNSURE ( 5.65 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Christophe JAILLET , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If 'devm_kmalloc_array' returns NULL, we should return -ENOMEM as already done a few lines above instead of deferencing a NULL pointer a few lines below. Signed-off-by: Christophe JAILLET Reviewed-by: Matthias Brugger --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 6582e1f56d37..cb32c9369f3a 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -559,6 +559,8 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, mtk_crtc->ddp_comp = devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr, sizeof(*mtk_crtc->ddp_comp), GFP_KERNEL); + if (!mtk_crtc->ddp_comp) + return -ENOMEM; mtk_crtc->mutex = mtk_disp_mutex_get(priv->mutex_dev, pipe); if (IS_ERR(mtk_crtc->mutex)) {