crypto: amcc: Hold the reference returned by of_find_compatible_node
Subsystems (2)
PATCH v2 1/2 crypto: amcc: Hold the reference returned by of_find_compatible_node
In crypto4xx_probe(), we should hold the reference returned by of_find_compatible_node() and use it to call of_node_put to keep
refcount balance.
---
changelog:
v2: split v1 into two commits, use short coding format for 'np=xx;'
v1: fix bugs in two directories (amcc,nx) of crypto
v1-link: https://lore.kernel.org/all/[email protected]/
drivers/crypto/amcc/crypto4xx_core.c | 40 +++++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-)
drivers/crypto/amcc/crypto4xx_core.c +24 -16
@@ -1378,6 +1378,7 @@ static int crypto4xx_probe(struct platform_device *ofdev)struct resource res;struct device *dev = &ofdev->dev;struct crypto4xx_core_device *core_dev; +struct device_node *np;u32 pvr;bool is_revb = true;
@@ -1385,29 +1386,36 @@ static int crypto4xx_probe(struct platform_device *ofdev)if (rc)return -ENODEV ; -if (of_find_compatible_node (NULL ,NULL ,"amcc,ppc460ex-crypto" )) { + np =of_find_compatible_node (NULL ,NULL ,"amcc,ppc460ex-crypto" ); +if (np) {mtdcri (SDR0 ,PPC460EX_SDR0_SRST ,mfdcri (SDR0 ,PPC460EX_SDR0_SRST ) |PPC460EX_CE_RESET );mtdcri (SDR0 ,PPC460EX_SDR0_SRST ,mfdcri (SDR0 ,PPC460EX_SDR0_SRST ) & ~PPC460EX_CE_RESET ); - }else if (of_find_compatible_node (NULL ,NULL , -"amcc,ppc405ex-crypto" )) { -mtdcri (SDR0 ,PPC405EX_SDR0_SRST , -mfdcri (SDR0 ,PPC405EX_SDR0_SRST ) |PPC405EX_CE_RESET ); -mtdcri (SDR0 ,PPC405EX_SDR0_SRST , -mfdcri (SDR0 ,PPC405EX_SDR0_SRST ) & ~PPC405EX_CE_RESET ); - is_revb = false; - }else if (of_find_compatible_node (NULL ,NULL , -"amcc,ppc460sx-crypto" )) { -mtdcri (SDR0 ,PPC460SX_SDR0_SRST , -mfdcri (SDR0 ,PPC460SX_SDR0_SRST ) |PPC460SX_CE_RESET ); -mtdcri (SDR0 ,PPC460SX_SDR0_SRST , -mfdcri (SDR0 ,PPC460SX_SDR0_SRST ) & ~PPC460SX_CE_RESET ); }else { -printk (KERN_ERR "Crypto Function Not supported!\n" ); -return -EINVAL ; + np =of_find_compatible_node (NULL ,NULL ,"amcc,ppc405ex-crypto" ); +if (np) { +mtdcri (SDR0 ,PPC405EX_SDR0_SRST , +mfdcri (SDR0 ,PPC405EX_SDR0_SRST ) |PPC405EX_CE_RESET ); +mtdcri (SDR0 ,PPC405EX_SDR0_SRST , +mfdcri (SDR0 ,PPC405EX_SDR0_SRST ) & ~PPC405EX_CE_RESET ); + is_revb = false; + }else { + np =of_find_compatible_node (NULL ,NULL ,"amcc,ppc460sx-crypto" ); +if (np) { +mtdcri (SDR0 ,PPC460SX_SDR0_SRST , +mfdcri (SDR0 ,PPC460SX_SDR0_SRST ) |PPC460SX_CE_RESET ); +mtdcri (SDR0 ,PPC460SX_SDR0_SRST , +mfdcri (SDR0 ,PPC460SX_SDR0_SRST ) & ~PPC460SX_CE_RESET ); + }else { +printk (KERN_ERR "Crypto Function Not supported!\n" ); +return -EINVAL ; + } + } } +of_node_put (np); + core_dev =kzalloc (sizeof (struct crypto4xx_core_device ),GFP_KERNEL );if (!core_dev)return -ENOMEM ;
Signature · 1 line
2.25.1
PATCH v2 2/2 crypto: nx: Hold the reference returned by of_find_compatible_node
In nx842_pseries_init(), we should hold the reference returned by of_find_compatible_node() and use it to call of_node_put to keep refcount balance.
---
changelog:
v2: split v1 into two commits
v1: fix bugs in two directories (amcc,nx) of crypto
v1-link: https://lore.kernel.org/all/[email protected]/
drivers/crypto/nx/nx-common-pseries.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/crypto/nx/nx-common-pseries.c +4 -1
@@ -1208,10 +1208,13 @@ static struct vio_driver nx842_vio_driver = {static int __init nx842_pseries_init (void ) {struct nx842_devdata *new_devdata; +struct device_node *np;int ret; -if (!of_find_compatible_node (NULL ,NULL ,"ibm,compression" )) + np =of_find_compatible_node (NULL ,NULL ,"ibm,compression" ); +if (!np)return -ENODEV ; +of_node_put (np);RCU_INIT_POINTER (devdata,NULL ); new_devdata =kzalloc (sizeof (*new_devdata),GFP_KERNEL );
Signature · 1 line
2.25.1
Herbert Xu
maintainerQuoted 8 lines · Liang He
In
crypto4xx_probe(), we should hold the reference returned byof_find_compatible_node()and use it to callof_node_putto keep
refcount balance.Signed-off-by Liang He <[email protected]>---
changelog:
Quoted 7 lines
v2: split v1 into two commits, use short coding format for 'np=xx;'
v1: fix bugs in two directories (amcc,nx) of cryptov1-link: https://lore.kernel.org/all/[email protected]/
drivers/crypto/amcc/crypto4xx_core.c | 40 +++++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-)
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt