From: Ian Jackson Subject: Re: [PATCH] libxc/pm: Fix NULL pointer checks. Date: Tue, 10 Sep 2013 16:10:13 +0100 Message-ID: <21039.13909.932839.667087@mariner.uk.xensource.com> References: <1378805379-18700-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1378805379-18700-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org Andrew Cooper writes ("[PATCH] libxc/pm: Fix NULL pointer checks."): > Discovered by Coverity, > CIDs 1054968 1054969 1054970 1054971 1054972 1054973 10549704 > > This was broken by c/s 5cc436c1d2b3b0 which did a blanket change of 'int > xc_handle' -> 'xc_interface *xch'. The types got updated, but error > conditions were left as-were. (I suspect some sed was involved originally) I see this has been committed, but I feel moved to comment: ... > diff --git a/tools/libxc/xc_pm.c b/tools/libxc/xc_pm.c > index fa9b246..ea1e251 100644 > --- a/tools/libxc/xc_pm.c > +++ b/tools/libxc/xc_pm.c > @@ -285,7 +285,7 @@ int xc_set_cpufreq_gov(xc_interface *xch, int cpuid, char *govname) > DECLARE_SYSCTL; > char *scaling_governor = sysctl.u.pm_op.u.set_gov.scaling_governor; > > - if ( (xch < 0) || (!govname) ) > + if ( !xch || !govname ) > return -EINVAL; TBH I think callers who pass null xch's into xc should get a null pointer dereference, not EINVAL. But I don't propose to try to go through libxc and drain its crazy error handling swamp. Ian.