coresight: fix use-after-free in stm on secure boot devices

When the STM driver failed to register, the stmdrvdata variable becomes
dangling pointer which may cause APSS to crash.

Change-Id: I0e709ac180d8c946f25e026b23edadb08c82a1f3
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
This commit is contained in:
Charan Teja Reddy 2016-06-17 17:24:41 +05:30 committed by Gerrit - the friendly Code Review server
parent 56c4e8930e
commit 9ed4b8f4b2
1 changed files with 4 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -868,8 +868,6 @@ static int stm_probe(struct platform_device *pdev)
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
if (!drvdata)
return -ENOMEM;
/* Store the driver data pointer for use in exported functions */
stmdrvdata = drvdata;
drvdata->dev = &pdev->dev;
platform_set_drvdata(pdev, drvdata);
@ -948,6 +946,9 @@ static int stm_probe(struct platform_device *pdev)
if (boot_enable)
coresight_enable(drvdata->csdev);
/* Store the driver data pointer for use in exported functions */
stmdrvdata = drvdata;
return 0;
err:
coresight_unregister(drvdata->csdev);