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

crypto: caam - Use the preferred style for memory allocations

"The preferred form for passing a size of a struct is the following:

p = kmalloc(sizeof(*p), ...);
....

The preferred form for allocating a zeroed array is the following:

p = kcalloc(n, sizeof(...), ...); "

,so do as suggested.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Horia Geant? <horia.geanta@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Fabio Estevam and committed by
Herbert Xu
9c4f9733 a3c09550

+11 -15
+1 -1
drivers/crypto/caam/caamalg.c
··· 4314 4314 struct caam_crypto_alg *t_alg; 4315 4315 struct crypto_alg *alg; 4316 4316 4317 - t_alg = kzalloc(sizeof(struct caam_crypto_alg), GFP_KERNEL); 4317 + t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL); 4318 4318 if (!t_alg) { 4319 4319 pr_err("failed to allocate t_alg\n"); 4320 4320 return ERR_PTR(-ENOMEM);
+1 -1
drivers/crypto/caam/caamhash.c
··· 1841 1841 struct ahash_alg *halg; 1842 1842 struct crypto_alg *alg; 1843 1843 1844 - t_alg = kzalloc(sizeof(struct caam_hash_alg), GFP_KERNEL); 1844 + t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL); 1845 1845 if (!t_alg) { 1846 1846 pr_err("failed to allocate t_alg\n"); 1847 1847 return ERR_PTR(-ENOMEM);
+1 -1
drivers/crypto/caam/caamrng.c
··· 351 351 pr_err("Job Ring Device allocation for transform failed\n"); 352 352 return PTR_ERR(dev); 353 353 } 354 - rng_ctx = kmalloc(sizeof(struct caam_rng_ctx), GFP_DMA); 354 + rng_ctx = kmalloc(sizeof(*rng_ctx), GFP_DMA); 355 355 if (!rng_ctx) { 356 356 err = -ENOMEM; 357 357 goto free_caam_alloc;
+3 -5
drivers/crypto/caam/ctrl.c
··· 424 424 int pg_size; 425 425 int BLOCK_OFFSET = 0; 426 426 427 - ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(struct caam_drv_private), 428 - GFP_KERNEL); 427 + ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(*ctrlpriv), GFP_KERNEL); 429 428 if (!ctrlpriv) 430 429 return -ENOMEM; 431 430 ··· 582 583 of_device_is_compatible(np, "fsl,sec4.0-job-ring")) 583 584 rspec++; 584 585 585 - ctrlpriv->jrpdev = devm_kzalloc(&pdev->dev, 586 - sizeof(struct platform_device *) * rspec, 587 - GFP_KERNEL); 586 + ctrlpriv->jrpdev = devm_kcalloc(&pdev->dev, rspec, 587 + sizeof(*ctrlpriv->jrpdev), GFP_KERNEL); 588 588 if (ctrlpriv->jrpdev == NULL) { 589 589 ret = -ENOMEM; 590 590 goto iounmap_ctrl;
+5 -7
drivers/crypto/caam/jr.c
··· 410 410 goto out_free_irq; 411 411 412 412 error = -ENOMEM; 413 - jrp->inpring = dma_alloc_coherent(dev, sizeof(dma_addr_t) * JOBR_DEPTH, 414 - &inpbusaddr, GFP_KERNEL); 413 + jrp->inpring = dma_alloc_coherent(dev, sizeof(*jrp->inpring) * 414 + JOBR_DEPTH, &inpbusaddr, GFP_KERNEL); 415 415 if (!jrp->inpring) 416 416 goto out_free_irq; 417 417 418 - jrp->outring = dma_alloc_coherent(dev, sizeof(struct jr_outentry) * 418 + jrp->outring = dma_alloc_coherent(dev, sizeof(*jrp->outring) * 419 419 JOBR_DEPTH, &outbusaddr, GFP_KERNEL); 420 420 if (!jrp->outring) 421 421 goto out_free_inpring; 422 422 423 - jrp->entinfo = kzalloc(sizeof(struct caam_jrentry_info) * JOBR_DEPTH, 424 - GFP_KERNEL); 423 + jrp->entinfo = kcalloc(JOBR_DEPTH, sizeof(*jrp->entinfo), GFP_KERNEL); 425 424 if (!jrp->entinfo) 426 425 goto out_free_outring; 427 426 ··· 478 479 int error; 479 480 480 481 jrdev = &pdev->dev; 481 - jrpriv = devm_kmalloc(jrdev, sizeof(struct caam_drv_private_jr), 482 - GFP_KERNEL); 482 + jrpriv = devm_kmalloc(jrdev, sizeof(*jrpriv), GFP_KERNEL); 483 483 if (!jrpriv) 484 484 return -ENOMEM; 485 485