summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2010-06-04 08:44:02 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2010-06-10 19:02:05 -0700
commit8ff9b502cfce3828f7855ffba7949d6ebee34031 (patch)
tree8d109f56e0179a7543a862fb0ac49835951ef232
parentc5eb5d69e5183860185a05cfcce16af635cab9aa (diff)
Solaris: avoid memory leak if AGPIOC_INFO ioctl fails
Move malloc after ioctl, so we don't have to worry about free'ing the memory if the ioctl fails. [ This bug was found by the Parfait bug checking tool. For more information see http://research.sun.com/projects/parfait ] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
-rw-r--r--hw/xfree86/os-support/solaris/sun_agp.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/hw/xfree86/os-support/solaris/sun_agp.c b/hw/xfree86/os-support/solaris/sun_agp.c
index 734a6e1a6..9db5d6368 100644
--- a/hw/xfree86/os-support/solaris/sun_agp.c
+++ b/hw/xfree86/os-support/solaris/sun_agp.c
@@ -115,16 +115,16 @@ xf86GetAGPInfo(int screenNum)
if (!GARTInit(screenNum))
return NULL;
- if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
xf86DrvMsg(screenNum, X_ERROR,
- "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
+ "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
+ strerror(errno));
return NULL;
}
- if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
xf86DrvMsg(screenNum, X_ERROR,
- "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
- strerror(errno));
+ "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
return NULL;
}