Skip to content

Commit 69c3683

Browse files
kiiofkircdavem330
authored andcommitted
netconsole: avoid null pointer dereference at show_local_mac()
This patch avoids a null pointer dereference when we read local_mac for netconsole in configfs and shows default local mac address value. A null pointer dereference occurs when we call show_local_mac() via local_mac entry in configfs before we setup the content of netpoll using netpoll_setup(). Signed-off-by: Keiichi KII <k-keiichi@bx.jp.nec.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b5c15fc commit 69c3683

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/net/netconsole.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ static ssize_t show_local_mac(struct netconsole_target *nt, char *buf)
309309
struct net_device *dev = nt->np.dev;
310310

311311
DECLARE_MAC_BUF(mac);
312-
return snprintf(buf, PAGE_SIZE, "%s\n",
313-
print_mac(mac, dev->dev_addr));
312+
return snprintf(buf, PAGE_SIZE, "%s\n", dev ?
313+
print_mac(mac, dev->dev_addr) : "ff:ff:ff:ff:ff:ff");
314314
}
315315

316316
static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf)

0 commit comments

Comments
 (0)