From: Keiichi KII Date: Fri, 15 Feb 2008 10:01:58 +0000 (-0800) Subject: netconsole: avoid null pointer dereference at show_local_mac() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=69c3683ca7fe066ecba9e8a0424c5abd258a5d58;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: David S. Miller --- diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 31e047dd7bb3..501e451be911 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -309,8 +309,8 @@ static ssize_t show_local_mac(struct netconsole_target *nt, char *buf) struct net_device *dev = nt->np.dev; DECLARE_MAC_BUF(mac); - return snprintf(buf, PAGE_SIZE, "%s\n", - print_mac(mac, dev->dev_addr)); + return snprintf(buf, PAGE_SIZE, "%s\n", dev ? + print_mac(mac, dev->dev_addr) : "ff:ff:ff:ff:ff:ff"); } static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf)