aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/atm/he.c
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2016-09-08 09:43:37 -0400
committerDavid S. Miller <davem@davemloft.net>2016-09-09 22:27:32 -0400
commit2c4f414f0290e019d463f1f7f447807fd6a6470c (patch)
tree085e4cc12f46f4808d0c29124c61b9491091bafa /drivers/atm/he.c
parentd9e6620c8ee108f068cd703b3b82d9a8d38c1ada (diff)
ATM-ForeRunnerHE: Use kmalloc_array() in he_init_group()
* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. * Replace the specification of data types by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/atm/he.c')
-rw-r--r--drivers/atm/he.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index 0f5cb37636bc..31b513a23ae0 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -779,8 +779,9 @@ static int he_init_group(struct he_dev *he_dev, int group)
779 G0_RBPS_BS + (group * 32)); 779 G0_RBPS_BS + (group * 32));
780 780
781 /* bitmap table */ 781 /* bitmap table */
782 he_dev->rbpl_table = kmalloc(BITS_TO_LONGS(RBPL_TABLE_SIZE) 782 he_dev->rbpl_table = kmalloc_array(BITS_TO_LONGS(RBPL_TABLE_SIZE),
783 * sizeof(unsigned long), GFP_KERNEL); 783 sizeof(*he_dev->rbpl_table),
784 GFP_KERNEL);
784 if (!he_dev->rbpl_table) { 785 if (!he_dev->rbpl_table) {
785 hprintk("unable to allocate rbpl bitmap table\n"); 786 hprintk("unable to allocate rbpl bitmap table\n");
786 return -ENOMEM; 787 return -ENOMEM;
@@ -788,8 +789,9 @@ static int he_init_group(struct he_dev *he_dev, int group)
788 bitmap_zero(he_dev->rbpl_table, RBPL_TABLE_SIZE); 789 bitmap_zero(he_dev->rbpl_table, RBPL_TABLE_SIZE);
789 790
790 /* rbpl_virt 64-bit pointers */ 791 /* rbpl_virt 64-bit pointers */
791 he_dev->rbpl_virt = kmalloc(RBPL_TABLE_SIZE 792 he_dev->rbpl_virt = kmalloc_array(RBPL_TABLE_SIZE,
792 * sizeof(struct he_buff *), GFP_KERNEL); 793 sizeof(*he_dev->rbpl_virt),
794 GFP_KERNEL);
793 if (!he_dev->rbpl_virt) { 795 if (!he_dev->rbpl_virt) {
794 hprintk("unable to allocate rbpl virt table\n"); 796 hprintk("unable to allocate rbpl virt table\n");
795 goto out_free_rbpl_table; 797 goto out_free_rbpl_table;