提交 bef227c1 编写于 作者: I Ivan Bornyakov 提交者: David S. Miller

net: sfp: avoid EEPROM read of absent SFP module

If SFP module is not present, it is sensible to fail sfp_module_eeprom()
and sfp_module_eeprom_by_page() early to avoid excessive I2C transfers
which are garanteed to fail.
Suggested-by: NAndrew Lunn <andrew@lunn.ch>
Signed-off-by: NIvan Bornyakov <i.bornyakov@metrotek.ru>
Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 813c2dd7
...@@ -2487,6 +2487,9 @@ static int sfp_module_eeprom(struct sfp *sfp, struct ethtool_eeprom *ee, ...@@ -2487,6 +2487,9 @@ static int sfp_module_eeprom(struct sfp *sfp, struct ethtool_eeprom *ee,
unsigned int first, last, len; unsigned int first, last, len;
int ret; int ret;
if (!(sfp->state & SFP_F_PRESENT))
return -ENODEV;
if (ee->len == 0) if (ee->len == 0)
return -EINVAL; return -EINVAL;
...@@ -2519,6 +2522,9 @@ static int sfp_module_eeprom_by_page(struct sfp *sfp, ...@@ -2519,6 +2522,9 @@ static int sfp_module_eeprom_by_page(struct sfp *sfp,
const struct ethtool_module_eeprom *page, const struct ethtool_module_eeprom *page,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
if (!(sfp->state & SFP_F_PRESENT))
return -ENODEV;
if (page->bank) { if (page->bank) {
NL_SET_ERR_MSG(extack, "Banks not supported"); NL_SET_ERR_MSG(extack, "Banks not supported");
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册