From patchwork Wed Jan 7 22:29:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 5590781 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 36893BF6C3 for ; Thu, 8 Jan 2015 02:42:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A32D20380 for ; Thu, 8 Jan 2015 02:42:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 044F52037B for ; Thu, 8 Jan 2015 02:42:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EF8D6E67B; Wed, 7 Jan 2015 18:42:01 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 304 seconds by postgrey-1.34 at gabe; Wed, 07 Jan 2015 14:35:04 PST Received: from gw02.mail.saunalahti.fi (gw02.mail.saunalahti.fi [195.197.172.116]) by gabe.freedesktop.org (Postfix) with ESMTP id A65C789F19 for ; Wed, 7 Jan 2015 14:35:04 -0800 (PST) Received: from localhost.localdomain (a91-152-110-231.elisa-laajakaista.fi [91.152.110.231]) by gw02.mail.saunalahti.fi (Postfix) with ESMTP id 0598D4009D; Thu, 8 Jan 2015 00:29:53 +0200 (EET) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.14.7/8.14.7) with ESMTP id t07MTsdl006572; Thu, 8 Jan 2015 00:29:54 +0200 Received: (from andy@localhost) by localhost.localdomain (8.14.7/8.14.7/Submit) id t07MTqVv006571; Thu, 8 Jan 2015 00:29:52 +0200 X-Authentication-Warning: localhost.localdomain: andy set sender to andy.shevchenko@gmail.com using -f From: Andy Shevchenko To: dri-devel@lists.freedesktop.org, Alexandre Courbot , David Airlie Subject: [PATCH v1] drm/nouveau/clk: avoid potential null-dereference Date: Thu, 8 Jan 2015 00:29:50 +0200 Message-Id: <1420669790-6525-1-git-send-email-andy.shevchenko@gmail.com> X-Mailer: git-send-email 1.8.3.101.g727a46b X-Mailman-Approved-At: Wed, 07 Jan 2015 18:41:59 -0800 Cc: Andy Shevchenko 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We have to check pointer before usage. Reported-by: Andrey Karpov Signed-off-by: Andy Shevchenko --- drivers/gpu/drm/nouveau/core/subdev/clock/base.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/base.c b/drivers/gpu/drm/nouveau/core/subdev/clock/base.c index e51b72d..2e84436 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/clock/base.c +++ b/drivers/gpu/drm/nouveau/core/subdev/clock/base.c @@ -322,7 +322,6 @@ nouveau_pstate_new(struct nouveau_clock *clk, int idx) return 0; pstate = kzalloc(sizeof(*pstate), GFP_KERNEL); - cstate = &pstate->base; if (!pstate) return -ENOMEM; @@ -330,6 +329,9 @@ nouveau_pstate_new(struct nouveau_clock *clk, int idx) pstate->pstate = perfE.pstate; pstate->fanspeed = perfE.fanspeed; + + cstate = &pstate->base; + cstate->voltage = perfE.voltage; cstate->domain[nv_clk_src_core] = perfE.core; cstate->domain[nv_clk_src_shader] = perfE.shader;