Skip to content

Commit 421a704

Browse files
WorldofJARcraftkartben
authored andcommitted
net: gPTP: Fix pointer type in gptp_add_port
The number of ports in gptp_domain.default_ds.nb_ports is a uint8_t. A pointer to it is passed to gptp_add_port. However, in this method, the pointer is cast to an int pointer. The C compiler generates an int-size store for this. In addition to potentially overwriting adjacent attributes, on platforms such as RISC-V that do not support unaligned accesses, this causes an exception on access. This commit casts nb_ports to the correct type, uint8_t. Signed-off-by: Eric Ackermann <eric.ackermann@cispa.de>
1 parent 833bb66 commit 421a704

File tree

1 file changed

+1
-1
lines changed
  • subsys/net/l2/ethernet/gptp

1 file changed

+1
-1
lines changed

subsys/net/l2/ethernet/gptp/gptp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ static void gptp_thread(void *p1, void *p2, void *p3)
586586

587587
static void gptp_add_port(struct net_if *iface, void *user_data)
588588
{
589-
int *num_ports = user_data;
589+
uint8_t *num_ports = user_data;
590590
const struct device *clk;
591591

592592
if (*num_ports >= CONFIG_NET_GPTP_NUM_PORTS) {

0 commit comments

Comments
 (0)