Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+55 -44
+1 -1
drivers/char/hw_random/core.c
··· 68 68 size_t size = min_t(size_t, 16, rng_buffer_size()); 69 69 70 70 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); 72 72 mutex_unlock(&reading_mutex); 73 73 if (bytes_read > 0) 74 74 add_device_randomness(rng_buffer, bytes_read);
+19 -24
drivers/crypto/hisilicon/sec/sec_algs.c
··· 153 153 ctx->cipher_alg); 154 154 } 155 155 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 + 156 174 static int sec_alloc_and_fill_hw_sgl(struct sec_hw_sgl **sec_sgl, 157 175 dma_addr_t *psec_sgl, 158 176 struct scatterlist *sgl, ··· 217 199 return 0; 218 200 219 201 err_free_hw_sgls: 220 - sgl_current = *sec_sgl; 221 - while (sgl_current) { 222 - sgl_next = sgl_current->next; 223 - dma_pool_free(info->hw_sgl_pool, sgl_current, 224 - sgl_current->next_sgl); 225 - sgl_current = sgl_next; 226 - } 202 + sec_free_hw_sgl(*sec_sgl, *psec_sgl, info); 227 203 *psec_sgl = 0; 228 204 229 205 return ret; 230 - } 231 - 232 - static void sec_free_hw_sgl(struct sec_hw_sgl *hw_sgl, 233 - dma_addr_t psec_sgl, struct sec_dev_info *info) 234 - { 235 - struct sec_hw_sgl *sgl_current, *sgl_next; 236 - 237 - if (!hw_sgl) 238 - return; 239 - sgl_current = hw_sgl; 240 - while (sgl_current->next) { 241 - sgl_next = sgl_current->next; 242 - dma_pool_free(info->hw_sgl_pool, sgl_current, 243 - sgl_current->next_sgl); 244 - sgl_current = sgl_next; 245 - } 246 - dma_pool_free(info->hw_sgl_pool, hw_sgl, psec_sgl); 247 206 } 248 207 249 208 static int sec_alg_skcipher_setkey(struct crypto_skcipher *tfm,
+2 -2
drivers/crypto/hisilicon/zip/zip_crypto.c
··· 559 559 struct hisi_zip_ctx *ctx = crypto_tfm_ctx(acomp_req->base.tfm); 560 560 struct hisi_zip_qp_ctx *qp_ctx = &ctx->qp_ctx[QPC_COMP]; 561 561 struct hisi_zip_req *req; 562 - size_t head_size; 562 + int head_size; 563 563 int ret; 564 564 565 565 /* let's output compression head now */ ··· 567 567 if (head_size < 0) 568 568 return -ENOMEM; 569 569 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); 571 571 if (IS_ERR(req)) 572 572 return PTR_ERR(req); 573 573
+2 -5
drivers/crypto/hisilicon/zip/zip_main.c
··· 785 785 786 786 static int hisi_zip_sriov_enable(struct pci_dev *pdev, int max_vfs) 787 787 { 788 - #ifdef CONFIG_PCI_IOV 789 788 struct hisi_zip *hisi_zip = pci_get_drvdata(pdev); 790 789 int pre_existing_vfs, num_vfs, ret; 791 790 ··· 814 815 } 815 816 816 817 return num_vfs; 817 - #else 818 - return 0; 819 - #endif 820 818 } 821 819 822 820 static int hisi_zip_sriov_disable(struct pci_dev *pdev) ··· 944 948 .id_table = hisi_zip_dev_ids, 945 949 .probe = hisi_zip_probe, 946 950 .remove = hisi_zip_remove, 947 - .sriov_configure = hisi_zip_sriov_configure, 951 + .sriov_configure = IS_ENABLED(CONFIG_PCI_IOV) ? 952 + hisi_zip_sriov_configure : 0, 948 953 .err_handler = &hisi_zip_err_handler, 949 954 }; 950 955
+30 -12
drivers/crypto/inside-secure/safexcel.c
··· 1789 1789 }; 1790 1790 #endif 1791 1791 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 1796 + #if IS_ENABLED(CONFIG_OF) 1797 + int ofreg_rc = -EINVAL; /* Default safe value */ 1798 + #endif 1799 + 1792 1800 static int __init safexcel_init(void) 1793 1801 { 1794 - int rc; 1802 + #if IS_ENABLED(CONFIG_PCI) 1803 + /* Register PCI driver */ 1804 + pcireg_rc = pci_register_driver(&safexcel_pci_driver); 1805 + #endif 1795 1806 1796 1807 #if IS_ENABLED(CONFIG_OF) 1797 - /* Register platform driver */ 1798 - platform_driver_register(&crypto_safexcel); 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 1799 1822 #endif 1800 - 1801 - #if IS_ENABLED(CONFIG_PCI) 1802 - /* Register PCI driver */ 1803 - rc = pci_register_driver(&safexcel_pci_driver); 1804 - #endif 1805 - 1806 - return 0; 1807 1823 } 1808 1824 1809 1825 static void __exit safexcel_exit(void) 1810 1826 { 1811 1827 #if IS_ENABLED(CONFIG_OF) 1812 - /* Unregister platform driver */ 1828 + /* Unregister platform driver */ 1829 + if (!ofreg_rc) 1813 1830 platform_driver_unregister(&crypto_safexcel); 1814 1831 #endif 1815 1832 1816 1833 #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) 1818 1836 pci_unregister_driver(&safexcel_pci_driver); 1819 1837 #endif 1820 1838 }
+1
drivers/crypto/talitos.c
··· 3116 3116 break; 3117 3117 case CRYPTO_ALG_TYPE_AEAD: 3118 3118 crypto_unregister_aead(&t_alg->algt.alg.aead); 3119 + break; 3119 3120 case CRYPTO_ALG_TYPE_AHASH: 3120 3121 crypto_unregister_ahash(&t_alg->algt.alg.hash); 3121 3122 break;