Re: [PATCH net-next] fddi: defza: add missing pointer type cast

From
Maciej W. Rozycki <macro@orcam.me.uk>
Date
2021-10-25 17:10:14
Reply to
Jakub Kicinski, 2021-10-25
On Mon, 25 Oct 2021, Jakub Kicinski wrote:
hw_addr is a uint AKA unsigned int. dev_addr_set() takes
a u8 *.
 Hmm, that's for alignment purposes to keep accessors simple (and somewhat 
faster) as hardware ignores byte lane enables, though having had a look at 
`fza_reads' something seems fishy to me here and I think `hw_addr' should 
be `u64' rather than `uint[2]'.  I'll have to double-check alignments 
throughout `struct fza_cmd_init' too and possibly elsewhere.  Unaligned 
accesses will trap and will be emulated even in the kernel mode (we need 
that for some IP packet header processing too), but obviously performance 
will suck.
quoted hunk ↗ jump to hunk
diff --git a/drivers/net/fddi/defza.c b/drivers/net/fddi/defza.c
index 3a6b08eb5e1b..f5c25acaa577 100644
--- a/drivers/net/fddi/defza.c
+++ b/drivers/net/fddi/defza.c
@@ -1380,7 +1380,7 @@ static int fza_probe(struct device *bdev)
 		goto err_out_irq;
 
 	fza_reads(&init->hw_addr, &hw_addr, sizeof(hw_addr));
-	dev_addr_set(dev, &hw_addr);
+	dev_addr_set(dev, (u8 *)&hw_addr);
 A union would be cleaner rather than having the type punned, but let's 
keep it like you proposed for now.

Acked-by: Maciej W. Rozycki <macro@orcam.me.uk>

  Maciej
Thread (3 messages) 3 messages, 3 authors, 2021-10-25
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help