diff options
author | James Simmons <jsimmons@infradead.org> | 2015-01-13 15:18:28 -0700 |
---|---|---|
committer | James Simmons <jsimmons@infradead.org> | 2015-01-13 15:18:28 -0700 |
commit | 33fcaa11daeb7ca156fcdadd969ca7f950ce8401 (patch) | |
tree | 9c73f03c592eec9002da3ca4d1904be83b3550b4 | |
parent | 8ff8235260c035b960c3552df25a9784e1049f24 (diff) |
Fixes for various memory related problems discovered by cppcheck.
The errors are memory leaks, NULL dereferences, and double frees.
Signed-off-by: Oppen <mrugiero@gmail.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
-rw-r--r-- | src/via_3d.c | 8 | ||||
-rw-r--r-- | src/via_dri.c | 8 | ||||
-rw-r--r-- | src/via_driver.c | 8 | ||||
-rw-r--r-- | src/via_exa.c | 5 |
4 files changed, 20 insertions, 9 deletions
diff --git a/src/via_3d.c b/src/via_3d.c index 64f40ba..e2d04ff 100644 --- a/src/via_3d.c +++ b/src/via_3d.c @@ -257,8 +257,12 @@ viaSet3DCompositeOperator(Via3DState * v3d, CARD8 op) { ViaCompositeOperator *vOp = viaOperatorModes + op; - v3d->blendDirty = TRUE; - if (v3d && vOp->supported) { + if (v3d) + v3d->blendDirty = TRUE; + else + return; + + if (vOp->supported) { v3d->blendCol0 = vOp->col0 << 4; v3d->blendCol1 = vOp->col1 << 2; v3d->blendAl0 = vOp->al0 << 4; diff --git a/src/via_dri.c b/src/via_dri.c index c8d3180..2f21a2b 100644 --- a/src/via_dri.c +++ b/src/via_dri.c @@ -478,6 +478,14 @@ VIAInitVisualConfigs(ScreenPtr pScreen) if (i != numConfigs) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[dri] Incorrect " "initialization of visuals. Disabling DRI.\n"); + + if (pConfigs) + free(pConfigs); + if (pVIAConfigs) + free(pVIAConfigs); + if (pVIAConfigPtrs) + free(pVIAConfigPtrs); + return FALSE; } } diff --git a/src/via_driver.c b/src/via_driver.c index 0679cf2..2fd8f21 100644 --- a/src/via_driver.c +++ b/src/via_driver.c @@ -1028,7 +1028,9 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags) pVia->ChipRev = pciReadByte(pciTag(0, 0, 0), 0xF6); #endif } - free(pEnt); + + if (pEnt) + free(pEnt); xf86DrvMsg(pScrn->scrnIndex, from, "Chipset revision: %d\n", pVia->ChipRev); pVia->directRenderingType = DRI_NONE; @@ -1106,7 +1108,6 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags) */ if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support32bppFb)) { - free(pEnt); VIAFreeRec(pScrn); return FALSE; } else { @@ -1121,7 +1122,6 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given depth (%d) is not supported by this driver\n", pScrn->depth); - free(pEnt); VIAFreeRec(pScrn); return FALSE; } @@ -1137,7 +1137,6 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags) rgb zeros = { 0, 0, 0 }; if (!xf86SetWeight(pScrn, zeros, zeros)) { - free(pEnt); VIAFreeRec(pScrn); return FALSE; } else { @@ -1154,7 +1153,6 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" " (%s) is not supported at depth %d.\n", xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); - free(pEnt); VIAFreeRec(pScrn); return FALSE; } diff --git a/src/via_exa.c b/src/via_exa.c index d78a770..3ee4921 100644 --- a/src/via_exa.c +++ b/src/via_exa.c @@ -217,9 +217,10 @@ viaSetupCBuffer(ScrnInfoPtr pScrn, ViaCommandBuffer *cb, unsigned size) static void viaTearDownCBuffer(ViaCommandBuffer *cb) { - if (cb && cb->buf) + if (cb && cb->buf) { free(cb->buf); - cb->buf = NULL; + cb->buf = NULL; + } } /* |