Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c4f414f authored by Markus Elfring's avatar Markus Elfring Committed by David S. Miller
Browse files

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: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d9e6620c
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -779,8 +779,9 @@ static int he_init_group(struct he_dev *he_dev, int group)
		  G0_RBPS_BS + (group * 32));
		  G0_RBPS_BS + (group * 32));


	/* bitmap table */
	/* bitmap table */
	he_dev->rbpl_table = kmalloc(BITS_TO_LONGS(RBPL_TABLE_SIZE)
	he_dev->rbpl_table = kmalloc_array(BITS_TO_LONGS(RBPL_TABLE_SIZE),
				     * sizeof(unsigned long), GFP_KERNEL);
					   sizeof(*he_dev->rbpl_table),
					   GFP_KERNEL);
	if (!he_dev->rbpl_table) {
	if (!he_dev->rbpl_table) {
		hprintk("unable to allocate rbpl bitmap table\n");
		hprintk("unable to allocate rbpl bitmap table\n");
		return -ENOMEM;
		return -ENOMEM;
@@ -788,8 +789,9 @@ static int he_init_group(struct he_dev *he_dev, int group)
	bitmap_zero(he_dev->rbpl_table, RBPL_TABLE_SIZE);
	bitmap_zero(he_dev->rbpl_table, RBPL_TABLE_SIZE);


	/* rbpl_virt 64-bit pointers */
	/* rbpl_virt 64-bit pointers */
	he_dev->rbpl_virt = kmalloc(RBPL_TABLE_SIZE
	he_dev->rbpl_virt = kmalloc_array(RBPL_TABLE_SIZE,
				    * sizeof(struct he_buff *), GFP_KERNEL);
					  sizeof(*he_dev->rbpl_virt),
					  GFP_KERNEL);
	if (!he_dev->rbpl_virt) {
	if (!he_dev->rbpl_virt) {
		hprintk("unable to allocate rbpl virt table\n");
		hprintk("unable to allocate rbpl virt table\n");
		goto out_free_rbpl_table;
		goto out_free_rbpl_table;