提交 3c6a6910 编写于 作者: L Linus Torvalds

Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Pull crypto fixes froim Herbert Xu:
 "This fixes the following issues:

   - potential boot hang in hwrng

   - missing switch/break in talitos

   - bugs and warnings in hisilicon

   - build warning in inside-secure"

* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
  crypto: hisilicon - avoid unused function warning
  hwrng: core - don't wait on add_early_randomness()
  crypto: hisilicon - Fix return value check in hisi_zip_acompress()
  crypto: hisilicon - Matching the dma address for dma_pool_free()
  crypto: hisilicon - Fix double free in sec_free_hw_sgl()
  crypto: inside-secure - Fix unused variable warning when CONFIG_PCI=n
  crypto: talitos - fix missing break in switch statement
...@@ -68,7 +68,7 @@ static void add_early_randomness(struct hwrng *rng) ...@@ -68,7 +68,7 @@ static void add_early_randomness(struct hwrng *rng)
size_t size = min_t(size_t, 16, rng_buffer_size()); size_t size = min_t(size_t, 16, rng_buffer_size());
mutex_lock(&reading_mutex); mutex_lock(&reading_mutex);
bytes_read = rng_get_data(rng, rng_buffer, size, 1); bytes_read = rng_get_data(rng, rng_buffer, size, 0);
mutex_unlock(&reading_mutex); mutex_unlock(&reading_mutex);
if (bytes_read > 0) if (bytes_read > 0)
add_device_randomness(rng_buffer, bytes_read); add_device_randomness(rng_buffer, bytes_read);
......
...@@ -153,6 +153,24 @@ static void sec_alg_skcipher_init_context(struct crypto_skcipher *atfm, ...@@ -153,6 +153,24 @@ static void sec_alg_skcipher_init_context(struct crypto_skcipher *atfm,
ctx->cipher_alg); ctx->cipher_alg);
} }
static void sec_free_hw_sgl(struct sec_hw_sgl *hw_sgl,
dma_addr_t psec_sgl, struct sec_dev_info *info)
{
struct sec_hw_sgl *sgl_current, *sgl_next;
dma_addr_t sgl_next_dma;
sgl_current = hw_sgl;
while (sgl_current) {
sgl_next = sgl_current->next;
sgl_next_dma = sgl_current->next_sgl;
dma_pool_free(info->hw_sgl_pool, sgl_current, psec_sgl);
sgl_current = sgl_next;
psec_sgl = sgl_next_dma;
}
}
static int sec_alloc_and_fill_hw_sgl(struct sec_hw_sgl **sec_sgl, static int sec_alloc_and_fill_hw_sgl(struct sec_hw_sgl **sec_sgl,
dma_addr_t *psec_sgl, dma_addr_t *psec_sgl,
struct scatterlist *sgl, struct scatterlist *sgl,
...@@ -199,35 +217,12 @@ static int sec_alloc_and_fill_hw_sgl(struct sec_hw_sgl **sec_sgl, ...@@ -199,35 +217,12 @@ static int sec_alloc_and_fill_hw_sgl(struct sec_hw_sgl **sec_sgl,
return 0; return 0;
err_free_hw_sgls: err_free_hw_sgls:
sgl_current = *sec_sgl; sec_free_hw_sgl(*sec_sgl, *psec_sgl, info);
while (sgl_current) {
sgl_next = sgl_current->next;
dma_pool_free(info->hw_sgl_pool, sgl_current,
sgl_current->next_sgl);
sgl_current = sgl_next;
}
*psec_sgl = 0; *psec_sgl = 0;
return ret; return ret;
} }
static void sec_free_hw_sgl(struct sec_hw_sgl *hw_sgl,
dma_addr_t psec_sgl, struct sec_dev_info *info)
{
struct sec_hw_sgl *sgl_current, *sgl_next;
if (!hw_sgl)
return;
sgl_current = hw_sgl;
while (sgl_current->next) {
sgl_next = sgl_current->next;
dma_pool_free(info->hw_sgl_pool, sgl_current,
sgl_current->next_sgl);
sgl_current = sgl_next;
}
dma_pool_free(info->hw_sgl_pool, hw_sgl, psec_sgl);
}
static int sec_alg_skcipher_setkey(struct crypto_skcipher *tfm, static int sec_alg_skcipher_setkey(struct crypto_skcipher *tfm,
const u8 *key, unsigned int keylen, const u8 *key, unsigned int keylen,
enum sec_cipher_alg alg) enum sec_cipher_alg alg)
......
...@@ -559,7 +559,7 @@ static int hisi_zip_acompress(struct acomp_req *acomp_req) ...@@ -559,7 +559,7 @@ static int hisi_zip_acompress(struct acomp_req *acomp_req)
struct hisi_zip_ctx *ctx = crypto_tfm_ctx(acomp_req->base.tfm); struct hisi_zip_ctx *ctx = crypto_tfm_ctx(acomp_req->base.tfm);
struct hisi_zip_qp_ctx *qp_ctx = &ctx->qp_ctx[QPC_COMP]; struct hisi_zip_qp_ctx *qp_ctx = &ctx->qp_ctx[QPC_COMP];
struct hisi_zip_req *req; struct hisi_zip_req *req;
size_t head_size; int head_size;
int ret; int ret;
/* let's output compression head now */ /* let's output compression head now */
...@@ -567,7 +567,7 @@ static int hisi_zip_acompress(struct acomp_req *acomp_req) ...@@ -567,7 +567,7 @@ static int hisi_zip_acompress(struct acomp_req *acomp_req)
if (head_size < 0) if (head_size < 0)
return -ENOMEM; return -ENOMEM;
req = hisi_zip_create_req(acomp_req, qp_ctx, head_size, true); req = hisi_zip_create_req(acomp_req, qp_ctx, (size_t)head_size, true);
if (IS_ERR(req)) if (IS_ERR(req))
return PTR_ERR(req); return PTR_ERR(req);
......
...@@ -785,7 +785,6 @@ static int hisi_zip_clear_vft_config(struct hisi_zip *hisi_zip) ...@@ -785,7 +785,6 @@ static int hisi_zip_clear_vft_config(struct hisi_zip *hisi_zip)
static int hisi_zip_sriov_enable(struct pci_dev *pdev, int max_vfs) static int hisi_zip_sriov_enable(struct pci_dev *pdev, int max_vfs)
{ {
#ifdef CONFIG_PCI_IOV
struct hisi_zip *hisi_zip = pci_get_drvdata(pdev); struct hisi_zip *hisi_zip = pci_get_drvdata(pdev);
int pre_existing_vfs, num_vfs, ret; int pre_existing_vfs, num_vfs, ret;
...@@ -815,9 +814,6 @@ static int hisi_zip_sriov_enable(struct pci_dev *pdev, int max_vfs) ...@@ -815,9 +814,6 @@ static int hisi_zip_sriov_enable(struct pci_dev *pdev, int max_vfs)
} }
return num_vfs; return num_vfs;
#else
return 0;
#endif
} }
static int hisi_zip_sriov_disable(struct pci_dev *pdev) static int hisi_zip_sriov_disable(struct pci_dev *pdev)
...@@ -948,7 +944,8 @@ static struct pci_driver hisi_zip_pci_driver = { ...@@ -948,7 +944,8 @@ static struct pci_driver hisi_zip_pci_driver = {
.id_table = hisi_zip_dev_ids, .id_table = hisi_zip_dev_ids,
.probe = hisi_zip_probe, .probe = hisi_zip_probe,
.remove = hisi_zip_remove, .remove = hisi_zip_remove,
.sriov_configure = hisi_zip_sriov_configure, .sriov_configure = IS_ENABLED(CONFIG_PCI_IOV) ?
hisi_zip_sriov_configure : 0,
.err_handler = &hisi_zip_err_handler, .err_handler = &hisi_zip_err_handler,
}; };
......
...@@ -1789,32 +1789,50 @@ static struct pci_driver safexcel_pci_driver = { ...@@ -1789,32 +1789,50 @@ static struct pci_driver safexcel_pci_driver = {
}; };
#endif #endif
static int __init safexcel_init(void) /* Unfortunately, we have to resort to global variables here */
{ #if IS_ENABLED(CONFIG_PCI)
int rc; int pcireg_rc = -EINVAL; /* Default safe value */
#endif
#if IS_ENABLED(CONFIG_OF) #if IS_ENABLED(CONFIG_OF)
/* Register platform driver */ int ofreg_rc = -EINVAL; /* Default safe value */
platform_driver_register(&crypto_safexcel);
#endif #endif
static int __init safexcel_init(void)
{
#if IS_ENABLED(CONFIG_PCI) #if IS_ENABLED(CONFIG_PCI)
/* Register PCI driver */ /* Register PCI driver */
rc = pci_register_driver(&safexcel_pci_driver); pcireg_rc = pci_register_driver(&safexcel_pci_driver);
#endif #endif
return 0; #if IS_ENABLED(CONFIG_OF)
/* Register platform driver */
ofreg_rc = platform_driver_register(&crypto_safexcel);
#if IS_ENABLED(CONFIG_PCI)
/* Return success if either PCI or OF registered OK */
return pcireg_rc ? ofreg_rc : 0;
#else
return ofreg_rc;
#endif
#else
#if IS_ENABLED(CONFIG_PCI)
return pcireg_rc;
#else
return -EINVAL;
#endif
#endif
} }
static void __exit safexcel_exit(void) static void __exit safexcel_exit(void)
{ {
#if IS_ENABLED(CONFIG_OF) #if IS_ENABLED(CONFIG_OF)
/* Unregister platform driver */ /* Unregister platform driver */
if (!ofreg_rc)
platform_driver_unregister(&crypto_safexcel); platform_driver_unregister(&crypto_safexcel);
#endif #endif
#if IS_ENABLED(CONFIG_PCI) #if IS_ENABLED(CONFIG_PCI)
/* Unregister PCI driver if successfully registered before */ /* Unregister PCI driver if successfully registered before */
if (!pcireg_rc)
pci_unregister_driver(&safexcel_pci_driver); pci_unregister_driver(&safexcel_pci_driver);
#endif #endif
} }
......
...@@ -3116,6 +3116,7 @@ static int talitos_remove(struct platform_device *ofdev) ...@@ -3116,6 +3116,7 @@ static int talitos_remove(struct platform_device *ofdev)
break; break;
case CRYPTO_ALG_TYPE_AEAD: case CRYPTO_ALG_TYPE_AEAD:
crypto_unregister_aead(&t_alg->algt.alg.aead); crypto_unregister_aead(&t_alg->algt.alg.aead);
break;
case CRYPTO_ALG_TYPE_AHASH: case CRYPTO_ALG_TYPE_AHASH:
crypto_unregister_ahash(&t_alg->algt.alg.hash); crypto_unregister_ahash(&t_alg->algt.alg.hash);
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册