mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-09-03 10:33:11 +02:00
Add missing NULL checks in CAAM sm
Missing NULL checks in CAAM sm_store and sm_test cause kernel crashes if caam init fails. Signed-off-by: Radu Solea <radu.solea@nxp.com> Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
This commit is contained in:
parent
0e6ed5a819
commit
b1254b6b5f
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* CAAM Secure Memory Storage Interface
|
||||
* Copyright (C) 2008-2015 Freescale Semiconductor, Inc.
|
||||
|
@ -1004,6 +1003,13 @@ int caam_sm_startup(struct platform_device *pdev)
|
|||
ctrldev = &pdev->dev;
|
||||
ctrlpriv = dev_get_drvdata(ctrldev);
|
||||
|
||||
/*
|
||||
* If ctrlpriv is NULL, it's probably because the caam driver wasn't
|
||||
* properly initialized (e.g. RNG4 init failed). Thus, bail out here.
|
||||
*/
|
||||
if (!ctrlpriv)
|
||||
return -ENODEV;
|
||||
|
||||
/*
|
||||
* Set up the private block for secure memory
|
||||
* Only one instance is possible
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
* Secure Memory / Keystore Exemplification Module
|
||||
* Copyright (C) 2012-2015 Freescale Semiconductor, Inc. All Rights Reserved
|
||||
|
@ -106,6 +105,14 @@ int caam_sm_example_init(struct platform_device *pdev)
|
|||
*/
|
||||
ctrldev = &pdev->dev;
|
||||
ctrlpriv = dev_get_drvdata(ctrldev);
|
||||
|
||||
/*
|
||||
* If ctrlpriv is NULL, it's probably because the caam driver wasn't
|
||||
* properly initialized (e.g. RNG4 init failed). Thus, bail out here.
|
||||
*/
|
||||
if (!ctrlpriv)
|
||||
return -ENODEV;
|
||||
|
||||
ksdev = ctrlpriv->smdev;
|
||||
kspriv = dev_get_drvdata(ksdev);
|
||||
if (kspriv == NULL)
|
||||
|
|
Loading…
Reference in New Issue
Block a user