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

Commit e6bd4486 authored by Andrey Smirnov's avatar Andrey Smirnov Committed by Wim Van Sebroeck
Browse files

watchdog: ziirave_wdt: Fix incorrect use of ARRAY_SIZE



Both memset() and ziirave_firm_write_block_data() expect length in
bytes as an argument, not a number of elements in array. It just
happens that in this particular case both values are equal. Modify the
code to use sizeof() instead.

Signed-off-by: default avatarAndrey Smirnov <andrew.smirnov@gmail.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Rick Ramstetter <rick@anteaterllc.com>
Cc: linux-watchdog@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20190812200906.31344-10-andrew.smirnov@gmail.com


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
parent dc0dd289
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ static int ziirave_firm_set_read_addr(struct watchdog_device *wdd, u16 addr)

	return i2c_smbus_write_block_data(client,
					  ZIIRAVE_CMD_DOWNLOAD_SET_READ_ADDR,
					  ARRAY_SIZE(address), address);
					  sizeof(address), address);
}

static int ziirave_firm_write_block_data(struct watchdog_device *wdd,
@@ -260,7 +260,7 @@ static int __ziirave_firm_write_pkt(struct watchdog_device *wdd,
		return -EMSGSIZE;
	}

	memset(packet, 0, ARRAY_SIZE(packet));
	memset(packet, 0, sizeof(packet));

	/* Packet length */
	packet[0] = len;
@@ -276,7 +276,7 @@ static int __ziirave_firm_write_pkt(struct watchdog_device *wdd,
	packet[ZIIRAVE_FIRM_PKT_TOTAL_SIZE - 1] = checksum;

	ret = ziirave_firm_write_block_data(wdd, ZIIRAVE_CMD_DOWNLOAD_PACKET,
					    ARRAY_SIZE(packet), packet, true);
					    sizeof(packet), packet, true);
	if (ret)
		dev_err(&client->dev,
		      "Failed to write firmware packet at address 0x%04x: %d\n",