From 51207cf118d9f3e6d3dd2e65f40a06da7fb7306a Mon Sep 17 00:00:00 2001 From: Kevin Brace Date: Thu, 4 Feb 2016 20:52:03 -0800 Subject: [PATCH] Fixing DVI detection code crash The portion of the code responsible for detecting VT1632A external TMDS transmitter for DVI was causing a crash if VT1632A was not detected on I2C buses. This was happening due to xf86DestroyI2CDevRec being called prior to the call to xf86I2CDevInit if VT1632A was not detected. Now the code will probe I2C buses using xf86I2CProbeAddress to look for VT1632A, and if VT1632A is not detected, it will stop trying to detect VT1632A via I2C buses. Signed-off-by: Kevin Brace --- src/via_outputs.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/via_outputs.c b/src/via_outputs.c index ef48226..bfe3809 100644 --- a/src/via_outputs.c +++ b/src/via_outputs.c @@ -1026,28 +1026,29 @@ via_dvi_init(ScrnInfoPtr pScrn) struct ViaVT1632PrivateData *private_data = NULL; I2CBusPtr pBus = NULL; I2CDevPtr pDev = NULL; + I2CSlaveAddr addr = 0x10; if (!pVia->pI2CBus2 || !pVia->pI2CBus3) { return; } - pDev = xf86CreateI2CDevRec(); - if (!pDev) { + if (xf86I2CProbeAddress(pVia->pI2CBus3, addr)) { + pBus = pVia->pI2CBus3; + } else if (xf86I2CProbeAddress(pVia->pI2CBus2, addr)) { + pBus = pVia->pI2CBus2; + } else { return; } - pDev->DevName = "VT1632"; - pDev->SlaveAddr = 0x10; - - if (xf86I2CProbeAddress(pVia->pI2CBus3, pDev->SlaveAddr)) { - pDev->pI2CBus = pVia->pI2CBus3; - } else if (xf86I2CProbeAddress(pVia->pI2CBus2, pDev->SlaveAddr)) { - pDev->pI2CBus = pVia->pI2CBus2; - } else { - xf86DestroyI2CDevRec(pDev, TRUE); + pDev = xf86CreateI2CDevRec(); + if (!pDev) { return; } + pDev->DevName = "VT1632A"; + pDev->SlaveAddr = addr; + pDev->pI2CBus = pBus; + if (!xf86I2CDevInit(pDev)) { xf86DestroyI2CDevRec(pDev, TRUE); return; -- 1.7.9.5