From patchwork Mon Jan 22 18:10:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10179019 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 3DC94601D5 for ; Mon, 22 Jan 2018 18:11:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3652828468 for ; Mon, 22 Jan 2018 18:11:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 298692846D; Mon, 22 Jan 2018 18:11:09 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D46BA28468 for ; Mon, 22 Jan 2018 18:11:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 89E706E296; Mon, 22 Jan 2018 18:11:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3FD086E288; Mon, 22 Jan 2018 18:10:53 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 258126079C; Mon, 22 Jan 2018 18:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516644653; bh=4uNS8VTIBrmTiy+tAMRegaPj6ybJBrrWGmCNM9oHULc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dIKU9V1bnSGOW2MXY6CSIcPnFlQVaVAKI08sMayRgQngeaS26g1Ja/HH396OX+IG+ RmzC+YLzR+MqaBXe5VcWY8kpIf+tUVnC0BcjLP19dRaGpUByNdvqxURl5TgxLAYYDT /nJIjz5MGN46C8v0j2Tre2eOQ5+ewphZttM4w3P4= Received: from jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 762CE6079C; Mon, 22 Jan 2018 18:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516644652; bh=4uNS8VTIBrmTiy+tAMRegaPj6ybJBrrWGmCNM9oHULc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IIEf7GQXAbuqqpDd04aeglgO7/PXlqWiw6UEOxDWN1hB5qf8frO4vWWkry5dTgqNn 8+uyirNZx1MDrGTeuhzF5ctkWSY/utMhTHorRpj4V81U10FFaNqsLtVSkYqP2YHecG xRFFwTZg8Z2A2RDGJiskSEXxbom5bQxAuFrZlm78= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 762CE6079C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org From: Jordan Crouse To: freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH 3/5] drm/msm/gpu: Set number of clocks to 0 if the list allocation fails Date: Mon, 22 Jan 2018 11:10:45 -0700 Message-Id: <1516644647-7507-4-git-send-email-jcrouse@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1516644647-7507-1-git-send-email-jcrouse@codeaurora.org> References: <1516644647-7507-1-git-send-email-jcrouse@codeaurora.org> Cc: linux-arm-msm@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP If we fail to allocate gpu->grp_clks reset the number of available clocks to zero to avoid referencing the missing array later. Signed-off-by: Jordan Crouse --- drivers/gpu/drm/msm/msm_gpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index bd376f9..2a80efd 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -682,8 +682,10 @@ static int get_clocks(struct platform_device *pdev, struct msm_gpu *gpu) gpu->grp_clks = devm_kcalloc(dev, sizeof(struct clk *), gpu->nr_clocks, GFP_KERNEL); - if (!gpu->grp_clks) + if (!gpu->grp_clks) { + gpu->nr_clocks = 0; return -ENOMEM; + } of_property_for_each_string(dev->of_node, "clock-names", prop, name) { gpu->grp_clks[i] = get_clock(dev, name);