From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753283AbcHUVGI (ORCPT ); Sun, 21 Aug 2016 17:06:08 -0400 Received: from smtprelay0141.hostedemail.com ([216.40.44.141]:33854 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752602AbcHUVGH (ORCPT ); Sun, 21 Aug 2016 17:06:07 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3868:3870:3871:3872:4250:4321:5007:7903:10004:10400:10848:11026:11232:11657:11658:11783:11914:12043:12114:12296:12438:12517:12519:12740:13069:13311:13357:13439:13894:14181:14659:14721:21080:30054:30064:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:3,LUA_SUMMARY:none X-HE-Tag: trees82_521d33e8b5353 X-Filterd-Recvd-Size: 1917 Message-ID: <1471813562.3746.23.camel@perches.com> Subject: Re: [PATCH 1/1] drm/radeon: avoid NULL dereference, si_get_vce_clock_voltage From: Joe Perches To: Heinrich Schuchardt , Alex Deucher , Christian =?ISO-8859-1?Q?K=F6nig?= Cc: David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Sun, 21 Aug 2016 14:06:02 -0700 In-Reply-To: <1471812743-5095-1-git-send-email-xypron.glpk@gmx.de> References: <1471812743-5095-1-git-send-email-xypron.glpk@gmx.de> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2016-08-21 at 22:52 +0200, Heinrich Schuchardt wrote: > It does not make sense to check if table is NULL > and afterwards to dereference it without > considering the result. This makes no sense. > The inconsistency was indicated by cppcheck. Perhaps this is a defect in cppcheck? > An actual NULL pointer dereference was not observed. [] > diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c [] > @@ -2962,7 +2962,7 @@ static int si_get_vce_clock_voltage(struct radeon_device *rdev, >   &rdev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table; >   >   if (((evclk == 0) && (ecclk == 0)) || > -     (table && (table->count == 0))) { Here table is only dereferenced if table is non-null > +     table == NULL || table->count == 0) { >   *voltage = 0; >   return 0; >   } Perhaps the unnecessary parentheses can be reduce though.   if ((evclk == 0 && ecclk == 0) || (table && table->count == 0)) {