drm/radeon: Fix stack data leak
Subsystems (2)
PATCH 1/1 drm/radeon: Fix stack data leak
Always zero-init a structure on the stack which is returned by a function. Otherwise you may leak random stack data from previous function calls.
This fixes the following warning I was seeing:
CC [M] drivers/gpu/drm/radeon/radeon_atombios.odrivers/gpu/drm/radeon/radeon_atombios.c: In function "radeon_atom_get_hpd_info_from_gpio":drivers/gpu/drm/radeon/radeon_atombios.c:261: warning: "hpd.plugged_state" is used uninitialized in this function
---
As a side, note, passing whole structures on the stack this way seems suboptimal. Passing structures by address would be faster (and safer, as it stands.)
drivers/gpu/drm/radeon/radeon_atombios.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/radeon/radeon_atombios.c +2 -0
@@ -226,6 +226,8 @@ static struct radeon_hpd radeon_atom_getstruct radeon_hpd hpd;u32 reg; +memset (&hpd,0 ,sizeof (struct radeon_hpd )); +if (ASIC_IS_DCE4 (rdev)) reg =EVERGREEN_DC_GPIO_HPD_A ;else
Signature · 1 line
Jean Delvare
Quoted 9 lines · Jean Delvare
Always zero-init a structure on the stack which is returned by a function. Otherwise you may leak random stack data from previous function calls.
This fixes the following warning I was seeing:
CC [M] drivers/gpu/drm/radeon/radeon_atombios.odrivers/gpu/drm/radeon/radeon_atombios.c: In function "radeon_atom_get_hpd_info_from_gpio":drivers/gpu/drm/radeon/radeon_atombios.c:261: warning: "hpd.plugged_state" is used uninitialized in this function
Quoted 7 lines
Signed-off-by Jean Delvare <[email protected]>Cc David Airlie <[email protected]>Cc Alex Deucher <[email protected]>---
As a side, note, passing whole structures on the stack this way seems suboptimal. Passing structures by address would be faster (and safer, as it stands.)
There are a few places in the connector/encoder init code where this needs to be cleaned up, just haven't gotten to it yet. Patch looks good. Thanks!
Quoted 20 lines
drivers/gpu/drm/radeon/radeon_atombios.c | 2 ++
1 file changed, 2 insertions(+)drivers/gpu/drm/radeon/radeon_atombios.c 2010-08-15 13:52:31.000000000 +0200 renamed from drivers/gpu/drm/radeon/radeon_atombios.c 2010-08-15 10:24:49.000000000 +0200 +2
-0@@ -226,6 +226,8 @@ static struct radeon_hpd radeon_atom_get struct radeon_hpd hpd; u32 reg; + memset(&hpd, 0, sizeof(struct radeon_hpd)); + if (ASIC_IS_DCE4(rdev)) reg = EVERGREEN_DC_GPIO_HPD_A;else
--
Jean Delvare