[PATCH 3.12 048/235] drivers/gpu/drm/ast: Fix infinite loop if read fails

From: Jiri Slaby
Date: Fri Jan 27 2017 - 06:00:05 EST

From: Russell Currey <ruscur@xxxxxxxxxx>

3.12-stable review patch. If anyone has any objections, please let me know.


commit 298360af3dab45659810fdc51aba0c9f4097e4f6 upstream.

ast_get_dram_info() configures a window in order to access BMC memory.
A BMC register can be configured to disallow this, and if so, causes
an infinite loop in the ast driver which renders the system unusable.

Fix this by erroring out if an error is detected. On powerpc systems with
EEH, this leads to the device being fenced and the system continuing to

Signed-off-by: Russell Currey <ruscur@xxxxxxxxxx>
Reviewed-by: Joel Stanley <joel@xxxxxxxxx>
Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxx>
Link: http://patchwork.freedesktop.org/patch/msgid/20161215051241.20815-1-ruscur@xxxxxxxxxx
Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
drivers/gpu/drm/ast/ast_main.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 88fc3a5fa7c4..32be5cb1f797 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -120,7 +120,8 @@ static int ast_get_dram_info(struct drm_device *dev)
ast_write32(ast, 0x10000, 0xfc600309);

do {
- ;
+ if (pci_channel_offline(dev->pdev))
+ return -EIO;
} while (ast_read32(ast, 0x10000) != 0x01);
data = ast_read32(ast, 0x10004);

@@ -343,7 +344,9 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)

if (ast->chip != AST1180) {
- ast_get_dram_info(dev);
+ ret = ast_get_dram_info(dev);
+ if (ret)
+ goto out_free;
ast->vram_size = ast_get_vram_info(dev);
DRM_INFO("dram %d %d %d %08x\n", ast->mclk, ast->dram_type, ast->dram_bus_width, ast->vram_size);