intel, gma500, lvds: Fix use after free and mem leak in psb_intel_lvds_init()
authorJesper Juhl <jj@chaosbits.net>
Thu, 8 Mar 2012 16:00:58 +0000 (16:00 +0000)
committerDave Airlie <airlied@redhat.com>
Sat, 10 Mar 2012 13:05:37 +0000 (13:05 +0000)
commitaa7c62af10b6ba7f0496ee3a1a760ad216426720
tree25f67514f2fcfb7ed7f1859053d83b2f09f469b9
parent05442e5e1ff1e75868e4f83822775f41e18c63b4
intel, 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>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/gma500/psb_intel_lvds.c