net: gemini: Avoid NULL dereference

When setting up the software queue depth one port need to peek
at the other port, but it may happen that the other port is
not yet up. We were a bit careless in dereferencing that
port, resulting in an oops:

  Unable to handle kernel paging request at virtual address e004402d
  gemini-ethernet-port 60008000.ethernet-port eth0: link flow control: both
  pgd = 0af63515
  [e004402d] *pgd=00000000
  Internal error: Oops: 1 [#1] PREEMPT ARM
  (...)
  CPU: 0 PID: 1491 Comm: netifd Not tainted 5.10.28 #0
  Hardware name: Gemini (Device Tree)
  PC is at geth_resize_freeq+0x30/0x3b0
  LR is at gmac_open+0x50/0x31c

Being more careful in dereferencing port0 and port1 makes
the bug go away.

Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 file changed