Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

smsc911x: Fix crash seen if neither ACPI nor OF is configured or used

Commit 0b50dc4fc971 ("Convert smsc911x to use ACPI as well as DT") makes
the call to smsc911x_probe_config() unconditional, and no longer fails if
there is no device node. device_get_phy_mode() is called unconditionally,
and if there is no phy node configured returns an error code. This error
code is assigned to phy_interface, and interpreted elsewhere in the code
as valid phy mode. This in turn causes qemu to crash when running a
variant of realview_pb_defconfig.

qemu: hardware error: lan9118_read: Bad reg 0x86

Fixes: 0b50dc4fc971 ("Convert smsc911x to use ACPI as well as DT")
Cc: Jeremy Linton <jeremy.linton@arm.com>
Cc Graeme Gregory <graeme.gregory@linaro.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Guenter Roeck and committed by
David S. Miller
62ee783b c87acb25

+6 -1
+6 -1
drivers/net/ethernet/smsc/smsc911x.c
··· 2367 2367 static int smsc911x_probe_config(struct smsc911x_platform_config *config, 2368 2368 struct device *dev) 2369 2369 { 2370 + int phy_interface; 2370 2371 u32 width = 0; 2371 2372 2372 2373 if (!dev) 2373 2374 return -ENODEV; 2374 2375 2375 - config->phy_interface = device_get_phy_mode(dev); 2376 + phy_interface = device_get_phy_mode(dev); 2377 + if (phy_interface < 0) 2378 + return phy_interface; 2379 + 2380 + config->phy_interface = phy_interface; 2376 2381 2377 2382 device_get_mac_address(dev, config->mac, ETH_ALEN); 2378 2383