* [PATCH 0/2] Small cleanups for smsc and device property @ 2015-08-19 16:46 Jeremy Linton 2015-08-19 16:46 ` [PATCH 1/2] device property: Add ETH_ALEN check, update comments Jeremy Linton 2015-08-19 16:46 ` [PATCH 2/2] smsc911x: Remove dev==NULL check Jeremy Linton 0 siblings, 2 replies; 5+ messages in thread From: Jeremy Linton @ 2015-08-19 16:46 UTC (permalink / raw) To: netdev; +Cc: gregkh, steve.glendinning, linux, jeremy.linton These patches are against net-next. This patch set adds a length check to device_get_mac_addr() before calling is_valid_ether_addr(), it also removes an unisssary dev==null check. The remainder is updates to the comments. Jeremy Linton (2): device property: Add ETH_ALEN check, update comments. smsc911x: Remove dev==NULL check. drivers/base/property.c | 21 +++++++++++++-------- drivers/net/ethernet/smsc/smsc911x.c | 3 --- 2 files changed, 13 insertions(+), 11 deletions(-) -- 2.4.3 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] device property: Add ETH_ALEN check, update comments. 2015-08-19 16:46 [PATCH 0/2] Small cleanups for smsc and device property Jeremy Linton @ 2015-08-19 16:46 ` Jeremy Linton 2015-08-20 21:37 ` David Miller 2015-08-19 16:46 ` [PATCH 2/2] smsc911x: Remove dev==NULL check Jeremy Linton 1 sibling, 1 reply; 5+ messages in thread From: Jeremy Linton @ 2015-08-19 16:46 UTC (permalink / raw) To: netdev; +Cc: gregkh, steve.glendinning, linux, jeremy.linton This patch adds MAC address length check back into the device_get_mac_addr() function before calling is_valid_ether_addr() similar to the way the OF routine does it. Update the comments for the two new functions. Signed-off-by: Jeremy Linton <jeremy.linton@arm.com> --- drivers/base/property.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 2e8cd14..4c20828 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -537,7 +537,7 @@ bool device_dma_is_coherent(struct device *dev) EXPORT_SYMBOL_GPL(device_dma_is_coherent); /** - * device_get_phy_mode - Get phy mode for given device_node + * device_get_phy_mode - Get phy mode for given device * @dev: Pointer to the given device * * The function gets phy interface string from property 'phy-mode' or @@ -570,13 +570,18 @@ static void *device_get_mac_addr(struct device *dev, { int ret = device_property_read_u8_array(dev, name, addr, alen); - if (ret == 0 && is_valid_ether_addr(addr)) + if (ret == 0 && alen == ETH_ALEN && is_valid_ether_addr(addr)) return addr; return NULL; } /** - * Search the device tree for the best MAC address to use. 'mac-address' is + * device_get_mac_address - Get the MAC for a given device + * @dev: Pointer to the device + * @addr: Address of buffer to store the MAC in + * @alen: Length of the buffer pointed to by addr, should be ETH_ALEN + * + * Search the firmware node for the best MAC address to use. 'mac-address' is * checked first, because that is supposed to contain to "most recent" MAC * address. If that isn't set, then 'local-mac-address' is checked next, * because that is the default address. If that isn't set, then the obsolete @@ -587,11 +592,11 @@ static void *device_get_mac_addr(struct device *dev, * MAC address. * * All-zero MAC addresses are rejected, because those could be properties that - * exist in the device tree, but were not set by U-Boot. For example, the - * DTS could define 'mac-address' and 'local-mac-address', with zero MAC - * addresses. Some older U-Boots only initialized 'local-mac-address'. In - * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists - * but is all zeros. + * exist in the firmware tables, but were not updated by the firmware. For + * example, the DTS could define 'mac-address' and 'local-mac-address', with + * zero MAC addresses. Some older U-Boots only initialized 'local-mac-address'. + * In this case, the real MAC is in 'local-mac-address', and 'mac-address' + * exists but is all zeros. */ void *device_get_mac_address(struct device *dev, char *addr, int alen) { -- 2.4.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] device property: Add ETH_ALEN check, update comments. 2015-08-19 16:46 ` [PATCH 1/2] device property: Add ETH_ALEN check, update comments Jeremy Linton @ 2015-08-20 21:37 ` David Miller 0 siblings, 0 replies; 5+ messages in thread From: David Miller @ 2015-08-20 21:37 UTC (permalink / raw) To: jeremy.linton; +Cc: netdev, gregkh, steve.glendinning, linux From: Jeremy Linton <jeremy.linton@arm.com> Date: Wed, 19 Aug 2015 11:46:42 -0500 > This patch adds MAC address length check back into > the device_get_mac_addr() function before calling > is_valid_ether_addr() similar to the way the OF > routine does it. > > Update the comments for the two new functions. > > Signed-off-by: Jeremy Linton <jeremy.linton@arm.com> Applied. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] smsc911x: Remove dev==NULL check. 2015-08-19 16:46 [PATCH 0/2] Small cleanups for smsc and device property Jeremy Linton 2015-08-19 16:46 ` [PATCH 1/2] device property: Add ETH_ALEN check, update comments Jeremy Linton @ 2015-08-19 16:46 ` Jeremy Linton 2015-08-20 21:38 ` David Miller 1 sibling, 1 reply; 5+ messages in thread From: Jeremy Linton @ 2015-08-19 16:46 UTC (permalink / raw) To: netdev; +Cc: gregkh, steve.glendinning, linux, jeremy.linton The dev==NULL check in smsc911x_probe_config is useless and isn't providing any additional protection. If a fwnode doesn't exist then an appropriate error should be returned by device_get_phy_mode() covering the original case of a missing of/fwnode. Signed-off-by: Jeremy Linton <jeremy.linton@arm.com> --- drivers/net/ethernet/smsc/smsc911x.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index 34f9768..6eef325 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -2370,9 +2370,6 @@ static int smsc911x_probe_config(struct smsc911x_platform_config *config, int phy_interface; u32 width = 0; - if (!dev) - return -ENODEV; - phy_interface = device_get_phy_mode(dev); if (phy_interface < 0) return phy_interface; -- 2.4.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] smsc911x: Remove dev==NULL check. 2015-08-19 16:46 ` [PATCH 2/2] smsc911x: Remove dev==NULL check Jeremy Linton @ 2015-08-20 21:38 ` David Miller 0 siblings, 0 replies; 5+ messages in thread From: David Miller @ 2015-08-20 21:38 UTC (permalink / raw) To: jeremy.linton; +Cc: netdev, gregkh, steve.glendinning, linux From: Jeremy Linton <jeremy.linton@arm.com> Date: Wed, 19 Aug 2015 11:46:43 -0500 > The dev==NULL check in smsc911x_probe_config is useless > and isn't providing any additional protection. If a fwnode > doesn't exist then an appropriate error should be returned > by device_get_phy_mode() covering the original case > of a missing of/fwnode. > > Signed-off-by: Jeremy Linton <jeremy.linton@arm.com> Applied. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-08-20 21:38 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-08-19 16:46 [PATCH 0/2] Small cleanups for smsc and device property Jeremy Linton 2015-08-19 16:46 ` [PATCH 1/2] device property: Add ETH_ALEN check, update comments Jeremy Linton 2015-08-20 21:37 ` David Miller 2015-08-19 16:46 ` [PATCH 2/2] smsc911x: Remove dev==NULL check Jeremy Linton 2015-08-20 21:38 ` David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).