gma500, lvds: Fix use after free and mem leak in psb_intel_lvds_init()
authorJesper Juhl <jj@chaosbits.net>
Fri, 3 Feb 2012 22:14:19 +0000 (23:14 +0100)
committerJiri Kosina <jkosina@suse.cz>
Fri, 3 Feb 2012 22:14:23 +0000 (23:14 +0100)
commit4b2453114f770fe6b2fe5c191f9a1539f52ce2ce
treeb920c04e35b6a1c3f0176552433feebbd743d031
parent972c5ae961d6e5103e2b33d935cfa4145fd47140
gma500, lvds: Fix use after free and mem leak in psb_intel_lvds_init()

In psb_intel_lvds_init(), if we fail to allocate memory for
'psb_intel_connector' we free the memory we previously allocated for
'psb_intel_encoder', but we then proceed to use that free'd pointer
when we do 'psb_intel_encoder->dev_priv = lvds_priv;'.

We may also leak the memory we allocated for 'psb_intel_encoder' if we
'goto failed_connector;' and the variable goes out of scope.

While I was there anyway, I also removed the pointless 'if
(psb_intel_connector)' before freeing it at the 'failed_connector:'
label - kfree() deals gracefully with NULL pointers, so it is not
needed.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/gpu/drm/gma500/psb_intel_lvds.c