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>
This commit is contained in:
parent
c5eb5d69e5
commit
8ff9b502cf
@ -115,12 +115,6 @@ xf86GetAGPInfo(int screenNum)
|
|||||||
if (!GARTInit(screenNum))
|
if (!GARTInit(screenNum))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
|
|
||||||
xf86DrvMsg(screenNum, X_ERROR,
|
|
||||||
"xf86GetAGPInfo: Failed to allocate AgpInfo\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
|
if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
|
||||||
xf86DrvMsg(screenNum, X_ERROR,
|
xf86DrvMsg(screenNum, X_ERROR,
|
||||||
"xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
|
"xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
|
||||||
@ -128,6 +122,12 @@ xf86GetAGPInfo(int screenNum)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
|
||||||
|
xf86DrvMsg(screenNum, X_ERROR,
|
||||||
|
"xf86GetAGPInfo: Failed to allocate AgpInfo\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
info->bridgeId = agpinf.agpi_devid;
|
info->bridgeId = agpinf.agpi_devid;
|
||||||
info->agpMode = agpinf.agpi_mode;
|
info->agpMode = agpinf.agpi_mode;
|
||||||
info->base = agpinf.agpi_aperbase;
|
info->base = agpinf.agpi_aperbase;
|
||||||
|
Loading…
Reference in New Issue
Block a user