Skip to content

Commit 3c6a691

Browse files
committed
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
2 parents 619e17c + bf6a7a5 commit 3c6a691

File tree

6 files changed

+54
-43
lines changed

6 files changed

+54
-43
lines changed

drivers/char/hw_random/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void add_early_randomness(struct hwrng *rng)
6868
size_t size = min_t(size_t, 16, rng_buffer_size());
6969

7070
mutex_lock(&reading_mutex);
71-
bytes_read = rng_get_data(rng, rng_buffer, size, 1);
71+
bytes_read = rng_get_data(rng, rng_buffer, size, 0);
7272
mutex_unlock(&reading_mutex);
7373
if (bytes_read > 0)
7474
add_device_randomness(rng_buffer, bytes_read);

drivers/crypto/hisilicon/sec/sec_algs.c

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,24 @@ static void sec_alg_skcipher_init_context(struct crypto_skcipher *atfm,
153153
ctx->cipher_alg);
154154
}
155155

156+
static void sec_free_hw_sgl(struct sec_hw_sgl *hw_sgl,
157+
dma_addr_t psec_sgl, struct sec_dev_info *info)
158+
{
159+
struct sec_hw_sgl *sgl_current, *sgl_next;
160+
dma_addr_t sgl_next_dma;
161+
162+
sgl_current = hw_sgl;
163+
while (sgl_current) {
164+
sgl_next = sgl_current->next;
165+
sgl_next_dma = sgl_current->next_sgl;
166+
167+
dma_pool_free(info->hw_sgl_pool, sgl_current, psec_sgl);
168+
169+
sgl_current = sgl_next;
170+
psec_sgl = sgl_next_dma;
171+
}
172+
}
173+
156174
static int sec_alloc_and_fill_hw_sgl(struct sec_hw_sgl **sec_sgl,
157175
dma_addr_t *psec_sgl,
158176
struct scatterlist *sgl,
@@ -199,35 +217,12 @@ static int sec_alloc_and_fill_hw_sgl(struct sec_hw_sgl **sec_sgl,
199217
return 0;
200218

201219
err_free_hw_sgls:
202-
sgl_current = *sec_sgl;
203-
while (sgl_current) {
204-
sgl_next = sgl_current->next;
205-
dma_pool_free(info->hw_sgl_pool, sgl_current,
206-
sgl_current->next_sgl);
207-
sgl_current = sgl_next;
208-
}
220+
sec_free_hw_sgl(*sec_sgl, *psec_sgl, info);
209221
*psec_sgl = 0;
210222

211223
return ret;
212224
}
213225

214-
static void sec_free_hw_sgl(struct sec_hw_sgl *hw_sgl,
215-
dma_addr_t psec_sgl, struct sec_dev_info *info)
216-
{
217-
struct sec_hw_sgl *sgl_current, *sgl_next;
218-
219-
if (!hw_sgl)
220-
return;
221-
sgl_current = hw_sgl;
222-
while (sgl_current->next) {
223-
sgl_next = sgl_current->next;
224-
dma_pool_free(info->hw_sgl_pool, sgl_current,
225-
sgl_current->next_sgl);
226-
sgl_current = sgl_next;
227-
}
228-
dma_pool_free(info->hw_sgl_pool, hw_sgl, psec_sgl);
229-
}
230-
231226
static int sec_alg_skcipher_setkey(struct crypto_skcipher *tfm,
232227
const u8 *key, unsigned int keylen,
233228
enum sec_cipher_alg alg)

drivers/crypto/hisilicon/zip/zip_crypto.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,15 +559,15 @@ static int hisi_zip_acompress(struct acomp_req *acomp_req)
559559
struct hisi_zip_ctx *ctx = crypto_tfm_ctx(acomp_req->base.tfm);
560560
struct hisi_zip_qp_ctx *qp_ctx = &ctx->qp_ctx[QPC_COMP];
561561
struct hisi_zip_req *req;
562-
size_t head_size;
562+
int head_size;
563563
int ret;
564564

565565
/* let's output compression head now */
566566
head_size = add_comp_head(acomp_req->dst, qp_ctx->qp->req_type);
567567
if (head_size < 0)
568568
return -ENOMEM;
569569

570-
req = hisi_zip_create_req(acomp_req, qp_ctx, head_size, true);
570+
req = hisi_zip_create_req(acomp_req, qp_ctx, (size_t)head_size, true);
571571
if (IS_ERR(req))
572572
return PTR_ERR(req);
573573

drivers/crypto/hisilicon/zip/zip_main.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,6 @@ static int hisi_zip_clear_vft_config(struct hisi_zip *hisi_zip)
785785

786786
static int hisi_zip_sriov_enable(struct pci_dev *pdev, int max_vfs)
787787
{
788-
#ifdef CONFIG_PCI_IOV
789788
struct hisi_zip *hisi_zip = pci_get_drvdata(pdev);
790789
int pre_existing_vfs, num_vfs, ret;
791790

@@ -815,9 +814,6 @@ static int hisi_zip_sriov_enable(struct pci_dev *pdev, int max_vfs)
815814
}
816815

817816
return num_vfs;
818-
#else
819-
return 0;
820-
#endif
821817
}
822818

823819
static int hisi_zip_sriov_disable(struct pci_dev *pdev)
@@ -948,7 +944,8 @@ static struct pci_driver hisi_zip_pci_driver = {
948944
.id_table = hisi_zip_dev_ids,
949945
.probe = hisi_zip_probe,
950946
.remove = hisi_zip_remove,
951-
.sriov_configure = hisi_zip_sriov_configure,
947+
.sriov_configure = IS_ENABLED(CONFIG_PCI_IOV) ?
948+
hisi_zip_sriov_configure : 0,
952949
.err_handler = &hisi_zip_err_handler,
953950
};
954951

drivers/crypto/inside-secure/safexcel.c

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,32 +1789,50 @@ static struct pci_driver safexcel_pci_driver = {
17891789
};
17901790
#endif
17911791

1792-
static int __init safexcel_init(void)
1793-
{
1794-
int rc;
1795-
1792+
/* Unfortunately, we have to resort to global variables here */
1793+
#if IS_ENABLED(CONFIG_PCI)
1794+
int pcireg_rc = -EINVAL; /* Default safe value */
1795+
#endif
17961796
#if IS_ENABLED(CONFIG_OF)
1797-
/* Register platform driver */
1798-
platform_driver_register(&crypto_safexcel);
1797+
int ofreg_rc = -EINVAL; /* Default safe value */
17991798
#endif
18001799

1800+
static int __init safexcel_init(void)
1801+
{
18011802
#if IS_ENABLED(CONFIG_PCI)
1802-
/* Register PCI driver */
1803-
rc = pci_register_driver(&safexcel_pci_driver);
1803+
/* Register PCI driver */
1804+
pcireg_rc = pci_register_driver(&safexcel_pci_driver);
18041805
#endif
18051806

1806-
return 0;
1807+
#if IS_ENABLED(CONFIG_OF)
1808+
/* Register platform driver */
1809+
ofreg_rc = platform_driver_register(&crypto_safexcel);
1810+
#if IS_ENABLED(CONFIG_PCI)
1811+
/* Return success if either PCI or OF registered OK */
1812+
return pcireg_rc ? ofreg_rc : 0;
1813+
#else
1814+
return ofreg_rc;
1815+
#endif
1816+
#else
1817+
#if IS_ENABLED(CONFIG_PCI)
1818+
return pcireg_rc;
1819+
#else
1820+
return -EINVAL;
1821+
#endif
1822+
#endif
18071823
}
18081824

18091825
static void __exit safexcel_exit(void)
18101826
{
18111827
#if IS_ENABLED(CONFIG_OF)
1812-
/* Unregister platform driver */
1828+
/* Unregister platform driver */
1829+
if (!ofreg_rc)
18131830
platform_driver_unregister(&crypto_safexcel);
18141831
#endif
18151832

18161833
#if IS_ENABLED(CONFIG_PCI)
1817-
/* Unregister PCI driver if successfully registered before */
1834+
/* Unregister PCI driver if successfully registered before */
1835+
if (!pcireg_rc)
18181836
pci_unregister_driver(&safexcel_pci_driver);
18191837
#endif
18201838
}

drivers/crypto/talitos.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3116,6 +3116,7 @@ static int talitos_remove(struct platform_device *ofdev)
31163116
break;
31173117
case CRYPTO_ALG_TYPE_AEAD:
31183118
crypto_unregister_aead(&t_alg->algt.alg.aead);
3119+
break;
31193120
case CRYPTO_ALG_TYPE_AHASH:
31203121
crypto_unregister_ahash(&t_alg->algt.alg.hash);
31213122
break;

0 commit comments

Comments
 (0)