Skip to content

Commit

Permalink
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
torvalds committed Sep 23, 2019
2 parents 619e17c + bf6a7a5 commit 3c6a691
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 43 deletions.
2 changes: 1 addition & 1 deletion drivers/char/hw_random/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static void add_early_randomness(struct hwrng *rng)
size_t size = min_t(size_t, 16, rng_buffer_size());

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);
if (bytes_read > 0)
add_device_randomness(rng_buffer, bytes_read);
Expand Down
43 changes: 19 additions & 24 deletions drivers/crypto/hisilicon/sec/sec_algs.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ static void sec_alg_skcipher_init_context(struct crypto_skcipher *atfm,
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,
dma_addr_t *psec_sgl,
struct scatterlist *sgl,
Expand Down Expand Up @@ -199,35 +217,12 @@ static int sec_alloc_and_fill_hw_sgl(struct sec_hw_sgl **sec_sgl,
return 0;

err_free_hw_sgls:
sgl_current = *sec_sgl;
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;
}
sec_free_hw_sgl(*sec_sgl, *psec_sgl, info);
*psec_sgl = 0;

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,
const u8 *key, unsigned int keylen,
enum sec_cipher_alg alg)
Expand Down
4 changes: 2 additions & 2 deletions drivers/crypto/hisilicon/zip/zip_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,15 @@ 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_qp_ctx *qp_ctx = &ctx->qp_ctx[QPC_COMP];
struct hisi_zip_req *req;
size_t head_size;
int head_size;
int ret;

/* let's output compression head now */
head_size = add_comp_head(acomp_req->dst, qp_ctx->qp->req_type);
if (head_size < 0)
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))
return PTR_ERR(req);

Expand Down
7 changes: 2 additions & 5 deletions drivers/crypto/hisilicon/zip/zip_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
#ifdef CONFIG_PCI_IOV
struct hisi_zip *hisi_zip = pci_get_drvdata(pdev);
int pre_existing_vfs, num_vfs, ret;

Expand Down Expand Up @@ -815,9 +814,6 @@ static int hisi_zip_sriov_enable(struct pci_dev *pdev, int max_vfs)
}

return num_vfs;
#else
return 0;
#endif
}

static int hisi_zip_sriov_disable(struct pci_dev *pdev)
Expand Down Expand Up @@ -948,7 +944,8 @@ static struct pci_driver hisi_zip_pci_driver = {
.id_table = hisi_zip_dev_ids,
.probe = hisi_zip_probe,
.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,
};

Expand Down
40 changes: 29 additions & 11 deletions drivers/crypto/inside-secure/safexcel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1789,32 +1789,50 @@ static struct pci_driver safexcel_pci_driver = {
};
#endif

static int __init safexcel_init(void)
{
int rc;

/* Unfortunately, we have to resort to global variables here */
#if IS_ENABLED(CONFIG_PCI)
int pcireg_rc = -EINVAL; /* Default safe value */
#endif
#if IS_ENABLED(CONFIG_OF)
/* Register platform driver */
platform_driver_register(&crypto_safexcel);
int ofreg_rc = -EINVAL; /* Default safe value */
#endif

static int __init safexcel_init(void)
{
#if IS_ENABLED(CONFIG_PCI)
/* Register PCI driver */
rc = pci_register_driver(&safexcel_pci_driver);
/* Register PCI driver */
pcireg_rc = pci_register_driver(&safexcel_pci_driver);
#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)
{
#if IS_ENABLED(CONFIG_OF)
/* Unregister platform driver */
/* Unregister platform driver */
if (!ofreg_rc)
platform_driver_unregister(&crypto_safexcel);
#endif

#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);
#endif
}
Expand Down
1 change: 1 addition & 0 deletions drivers/crypto/talitos.c
Original file line number Diff line number Diff line change
Expand Up @@ -3116,6 +3116,7 @@ static int talitos_remove(struct platform_device *ofdev)
break;
case CRYPTO_ALG_TYPE_AEAD:
crypto_unregister_aead(&t_alg->algt.alg.aead);
break;
case CRYPTO_ALG_TYPE_AHASH:
crypto_unregister_ahash(&t_alg->algt.alg.hash);
break;
Expand Down

0 comments on commit 3c6a691

Please sign in to comment.