diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-13 12:51:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-13 12:51:17 -0400 |
commit | dac0bde43b0b3685390b68c9058bee36d4d5c747 (patch) | |
tree | ac59b309ca7b896cfc2245449d1c82f096adc6d4 /drivers/crypto | |
parent | 5ea6718b1f1bb58825426e19a21cdba47075a954 (diff) | |
parent | 00e87449430dc130b43d84bdee71ef94524d9c39 (diff) |
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu:
"This fixes a bug in the newly added Exynos5433 AES code as well as an
old one in the caam driver"
* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: caam - add missing put_device() call
crypto: s5p-sss - fix AES support for Exynos5433
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/caam/caamalg.c | 12 | ||||
-rw-r--r-- | drivers/crypto/caam/caamalg_qi.c | 11 | ||||
-rw-r--r-- | drivers/crypto/caam/caamhash.c | 18 | ||||
-rw-r--r-- | drivers/crypto/caam/caampkc.c | 14 | ||||
-rw-r--r-- | drivers/crypto/caam/caamrng.c | 22 | ||||
-rw-r--r-- | drivers/crypto/s5p-sss.c | 2 |
6 files changed, 51 insertions, 28 deletions
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 9eac5099098e..579578498deb 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c | |||
@@ -3455,7 +3455,6 @@ static int __init caam_algapi_init(void) | |||
3455 | { | 3455 | { |
3456 | struct device_node *dev_node; | 3456 | struct device_node *dev_node; |
3457 | struct platform_device *pdev; | 3457 | struct platform_device *pdev; |
3458 | struct device *ctrldev; | ||
3459 | struct caam_drv_private *priv; | 3458 | struct caam_drv_private *priv; |
3460 | int i = 0, err = 0; | 3459 | int i = 0, err = 0; |
3461 | u32 aes_vid, aes_inst, des_inst, md_vid, md_inst, ccha_inst, ptha_inst; | 3460 | u32 aes_vid, aes_inst, des_inst, md_vid, md_inst, ccha_inst, ptha_inst; |
@@ -3476,16 +3475,17 @@ static int __init caam_algapi_init(void) | |||
3476 | return -ENODEV; | 3475 | return -ENODEV; |
3477 | } | 3476 | } |
3478 | 3477 | ||
3479 | ctrldev = &pdev->dev; | 3478 | priv = dev_get_drvdata(&pdev->dev); |
3480 | priv = dev_get_drvdata(ctrldev); | ||
3481 | of_node_put(dev_node); | 3479 | of_node_put(dev_node); |
3482 | 3480 | ||
3483 | /* | 3481 | /* |
3484 | * If priv is NULL, it's probably because the caam driver wasn't | 3482 | * If priv is NULL, it's probably because the caam driver wasn't |
3485 | * properly initialized (e.g. RNG4 init failed). Thus, bail out here. | 3483 | * properly initialized (e.g. RNG4 init failed). Thus, bail out here. |
3486 | */ | 3484 | */ |
3487 | if (!priv) | 3485 | if (!priv) { |
3488 | return -ENODEV; | 3486 | err = -ENODEV; |
3487 | goto out_put_dev; | ||
3488 | } | ||
3489 | 3489 | ||
3490 | 3490 | ||
3491 | /* | 3491 | /* |
@@ -3626,6 +3626,8 @@ static int __init caam_algapi_init(void) | |||
3626 | if (registered) | 3626 | if (registered) |
3627 | pr_info("caam algorithms registered in /proc/crypto\n"); | 3627 | pr_info("caam algorithms registered in /proc/crypto\n"); |
3628 | 3628 | ||
3629 | out_put_dev: | ||
3630 | put_device(&pdev->dev); | ||
3629 | return err; | 3631 | return err; |
3630 | } | 3632 | } |
3631 | 3633 | ||
diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c index a15ce9213310..c61921d32489 100644 --- a/drivers/crypto/caam/caamalg_qi.c +++ b/drivers/crypto/caam/caamalg_qi.c | |||
@@ -2492,12 +2492,15 @@ static int __init caam_qi_algapi_init(void) | |||
2492 | * If priv is NULL, it's probably because the caam driver wasn't | 2492 | * If priv is NULL, it's probably because the caam driver wasn't |
2493 | * properly initialized (e.g. RNG4 init failed). Thus, bail out here. | 2493 | * properly initialized (e.g. RNG4 init failed). Thus, bail out here. |
2494 | */ | 2494 | */ |
2495 | if (!priv || !priv->qi_present) | 2495 | if (!priv || !priv->qi_present) { |
2496 | return -ENODEV; | 2496 | err = -ENODEV; |
2497 | goto out_put_dev; | ||
2498 | } | ||
2497 | 2499 | ||
2498 | if (caam_dpaa2) { | 2500 | if (caam_dpaa2) { |
2499 | dev_info(ctrldev, "caam/qi frontend driver not suitable for DPAA 2.x, aborting...\n"); | 2501 | dev_info(ctrldev, "caam/qi frontend driver not suitable for DPAA 2.x, aborting...\n"); |
2500 | return -ENODEV; | 2502 | err = -ENODEV; |
2503 | goto out_put_dev; | ||
2501 | } | 2504 | } |
2502 | 2505 | ||
2503 | /* | 2506 | /* |
@@ -2610,6 +2613,8 @@ static int __init caam_qi_algapi_init(void) | |||
2610 | if (registered) | 2613 | if (registered) |
2611 | dev_info(priv->qidev, "algorithms registered in /proc/crypto\n"); | 2614 | dev_info(priv->qidev, "algorithms registered in /proc/crypto\n"); |
2612 | 2615 | ||
2616 | out_put_dev: | ||
2617 | put_device(ctrldev); | ||
2613 | return err; | 2618 | return err; |
2614 | } | 2619 | } |
2615 | 2620 | ||
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index d7483e4d0ce2..b1eadc6652b5 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c | |||
@@ -1993,7 +1993,6 @@ static int __init caam_algapi_hash_init(void) | |||
1993 | { | 1993 | { |
1994 | struct device_node *dev_node; | 1994 | struct device_node *dev_node; |
1995 | struct platform_device *pdev; | 1995 | struct platform_device *pdev; |
1996 | struct device *ctrldev; | ||
1997 | int i = 0, err = 0; | 1996 | int i = 0, err = 0; |
1998 | struct caam_drv_private *priv; | 1997 | struct caam_drv_private *priv; |
1999 | unsigned int md_limit = SHA512_DIGEST_SIZE; | 1998 | unsigned int md_limit = SHA512_DIGEST_SIZE; |
@@ -2012,16 +2011,17 @@ static int __init caam_algapi_hash_init(void) | |||
2012 | return -ENODEV; | 2011 | return -ENODEV; |
2013 | } | 2012 | } |
2014 | 2013 | ||
2015 | ctrldev = &pdev->dev; | 2014 | priv = dev_get_drvdata(&pdev->dev); |
2016 | priv = dev_get_drvdata(ctrldev); | ||
2017 | of_node_put(dev_node); | 2015 | of_node_put(dev_node); |
2018 | 2016 | ||
2019 | /* | 2017 | /* |
2020 | * If priv is NULL, it's probably because the caam driver wasn't | 2018 | * If priv is NULL, it's probably because the caam driver wasn't |
2021 | * properly initialized (e.g. RNG4 init failed). Thus, bail out here. | 2019 | * properly initialized (e.g. RNG4 init failed). Thus, bail out here. |
2022 | */ | 2020 | */ |
2023 | if (!priv) | 2021 | if (!priv) { |
2024 | return -ENODEV; | 2022 | err = -ENODEV; |
2023 | goto out_put_dev; | ||
2024 | } | ||
2025 | 2025 | ||
2026 | /* | 2026 | /* |
2027 | * Register crypto algorithms the device supports. First, identify | 2027 | * Register crypto algorithms the device supports. First, identify |
@@ -2043,8 +2043,10 @@ static int __init caam_algapi_hash_init(void) | |||
2043 | * Skip registration of any hashing algorithms if MD block | 2043 | * Skip registration of any hashing algorithms if MD block |
2044 | * is not present. | 2044 | * is not present. |
2045 | */ | 2045 | */ |
2046 | if (!md_inst) | 2046 | if (!md_inst) { |
2047 | return -ENODEV; | 2047 | err = -ENODEV; |
2048 | goto out_put_dev; | ||
2049 | } | ||
2048 | 2050 | ||
2049 | /* Limit digest size based on LP256 */ | 2051 | /* Limit digest size based on LP256 */ |
2050 | if (md_vid == CHA_VER_VID_MD_LP256) | 2052 | if (md_vid == CHA_VER_VID_MD_LP256) |
@@ -2101,6 +2103,8 @@ static int __init caam_algapi_hash_init(void) | |||
2101 | list_add_tail(&t_alg->entry, &hash_list); | 2103 | list_add_tail(&t_alg->entry, &hash_list); |
2102 | } | 2104 | } |
2103 | 2105 | ||
2106 | out_put_dev: | ||
2107 | put_device(&pdev->dev); | ||
2104 | return err; | 2108 | return err; |
2105 | } | 2109 | } |
2106 | 2110 | ||
diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c index 77ab28a2811a..58285642306e 100644 --- a/drivers/crypto/caam/caampkc.c +++ b/drivers/crypto/caam/caampkc.c | |||
@@ -1042,8 +1042,10 @@ static int __init caam_pkc_init(void) | |||
1042 | * If priv is NULL, it's probably because the caam driver wasn't | 1042 | * If priv is NULL, it's probably because the caam driver wasn't |
1043 | * properly initialized (e.g. RNG4 init failed). Thus, bail out here. | 1043 | * properly initialized (e.g. RNG4 init failed). Thus, bail out here. |
1044 | */ | 1044 | */ |
1045 | if (!priv) | 1045 | if (!priv) { |
1046 | return -ENODEV; | 1046 | err = -ENODEV; |
1047 | goto out_put_dev; | ||
1048 | } | ||
1047 | 1049 | ||
1048 | /* Determine public key hardware accelerator presence. */ | 1050 | /* Determine public key hardware accelerator presence. */ |
1049 | if (priv->era < 10) | 1051 | if (priv->era < 10) |
@@ -1053,8 +1055,10 @@ static int __init caam_pkc_init(void) | |||
1053 | pk_inst = rd_reg32(&priv->ctrl->vreg.pkha) & CHA_VER_NUM_MASK; | 1055 | pk_inst = rd_reg32(&priv->ctrl->vreg.pkha) & CHA_VER_NUM_MASK; |
1054 | 1056 | ||
1055 | /* Do not register algorithms if PKHA is not present. */ | 1057 | /* Do not register algorithms if PKHA is not present. */ |
1056 | if (!pk_inst) | 1058 | if (!pk_inst) { |
1057 | return -ENODEV; | 1059 | err = -ENODEV; |
1060 | goto out_put_dev; | ||
1061 | } | ||
1058 | 1062 | ||
1059 | err = crypto_register_akcipher(&caam_rsa); | 1063 | err = crypto_register_akcipher(&caam_rsa); |
1060 | if (err) | 1064 | if (err) |
@@ -1063,6 +1067,8 @@ static int __init caam_pkc_init(void) | |||
1063 | else | 1067 | else |
1064 | dev_info(ctrldev, "caam pkc algorithms registered in /proc/crypto\n"); | 1068 | dev_info(ctrldev, "caam pkc algorithms registered in /proc/crypto\n"); |
1065 | 1069 | ||
1070 | out_put_dev: | ||
1071 | put_device(ctrldev); | ||
1066 | return err; | 1072 | return err; |
1067 | } | 1073 | } |
1068 | 1074 | ||
diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c index a387c8d49a62..95eb5402c59f 100644 --- a/drivers/crypto/caam/caamrng.c +++ b/drivers/crypto/caam/caamrng.c | |||
@@ -308,7 +308,6 @@ static int __init caam_rng_init(void) | |||
308 | struct device *dev; | 308 | struct device *dev; |
309 | struct device_node *dev_node; | 309 | struct device_node *dev_node; |
310 | struct platform_device *pdev; | 310 | struct platform_device *pdev; |
311 | struct device *ctrldev; | ||
312 | struct caam_drv_private *priv; | 311 | struct caam_drv_private *priv; |
313 | u32 rng_inst; | 312 | u32 rng_inst; |
314 | int err; | 313 | int err; |
@@ -326,16 +325,17 @@ static int __init caam_rng_init(void) | |||
326 | return -ENODEV; | 325 | return -ENODEV; |
327 | } | 326 | } |
328 | 327 | ||
329 | ctrldev = &pdev->dev; | 328 | priv = dev_get_drvdata(&pdev->dev); |
330 | priv = dev_get_drvdata(ctrldev); | ||
331 | of_node_put(dev_node); | 329 | of_node_put(dev_node); |
332 | 330 | ||
333 | /* | 331 | /* |
334 | * If priv is NULL, it's probably because the caam driver wasn't | 332 | * If priv is NULL, it's probably because the caam driver wasn't |
335 | * properly initialized (e.g. RNG4 init failed). Thus, bail out here. | 333 | * properly initialized (e.g. RNG4 init failed). Thus, bail out here. |
336 | */ | 334 | */ |
337 | if (!priv) | 335 | if (!priv) { |
338 | return -ENODEV; | 336 | err = -ENODEV; |
337 | goto out_put_dev; | ||
338 | } | ||
339 | 339 | ||
340 | /* Check for an instantiated RNG before registration */ | 340 | /* Check for an instantiated RNG before registration */ |
341 | if (priv->era < 10) | 341 | if (priv->era < 10) |
@@ -344,13 +344,16 @@ static int __init caam_rng_init(void) | |||
344 | else | 344 | else |
345 | rng_inst = rd_reg32(&priv->ctrl->vreg.rng) & CHA_VER_NUM_MASK; | 345 | rng_inst = rd_reg32(&priv->ctrl->vreg.rng) & CHA_VER_NUM_MASK; |
346 | 346 | ||
347 | if (!rng_inst) | 347 | if (!rng_inst) { |
348 | return -ENODEV; | 348 | err = -ENODEV; |
349 | goto out_put_dev; | ||
350 | } | ||
349 | 351 | ||
350 | dev = caam_jr_alloc(); | 352 | dev = caam_jr_alloc(); |
351 | if (IS_ERR(dev)) { | 353 | if (IS_ERR(dev)) { |
352 | pr_err("Job Ring Device allocation for transform failed\n"); | 354 | pr_err("Job Ring Device allocation for transform failed\n"); |
353 | return PTR_ERR(dev); | 355 | err = PTR_ERR(dev); |
356 | goto out_put_dev; | ||
354 | } | 357 | } |
355 | rng_ctx = kmalloc(sizeof(*rng_ctx), GFP_DMA | GFP_KERNEL); | 358 | rng_ctx = kmalloc(sizeof(*rng_ctx), GFP_DMA | GFP_KERNEL); |
356 | if (!rng_ctx) { | 359 | if (!rng_ctx) { |
@@ -361,6 +364,7 @@ static int __init caam_rng_init(void) | |||
361 | if (err) | 364 | if (err) |
362 | goto free_rng_ctx; | 365 | goto free_rng_ctx; |
363 | 366 | ||
367 | put_device(&pdev->dev); | ||
364 | dev_info(dev, "registering rng-caam\n"); | 368 | dev_info(dev, "registering rng-caam\n"); |
365 | return hwrng_register(&caam_rng); | 369 | return hwrng_register(&caam_rng); |
366 | 370 | ||
@@ -368,6 +372,8 @@ free_rng_ctx: | |||
368 | kfree(rng_ctx); | 372 | kfree(rng_ctx); |
369 | free_caam_alloc: | 373 | free_caam_alloc: |
370 | caam_jr_free(dev); | 374 | caam_jr_free(dev); |
375 | out_put_dev: | ||
376 | put_device(&pdev->dev); | ||
371 | return err; | 377 | return err; |
372 | } | 378 | } |
373 | 379 | ||
diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c index f4e625cf53ca..1afdcb81d8ed 100644 --- a/drivers/crypto/s5p-sss.c +++ b/drivers/crypto/s5p-sss.c | |||
@@ -241,7 +241,7 @@ | |||
241 | struct samsung_aes_variant { | 241 | struct samsung_aes_variant { |
242 | unsigned int aes_offset; | 242 | unsigned int aes_offset; |
243 | unsigned int hash_offset; | 243 | unsigned int hash_offset; |
244 | const char *clk_names[]; | 244 | const char *clk_names[2]; |
245 | }; | 245 | }; |
246 | 246 | ||
247 | struct s5p_aes_reqctx { | 247 | struct s5p_aes_reqctx { |