diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 992fcab4b552..8dd7c8e84a65 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -787,13 +787,15 @@ static int dsa_slave_get_sset_count(struct net_device *dev, int sset) struct dsa_switch *ds = dp->ds; if (sset == ETH_SS_STATS) { - int count; + int count = 0; - count = 4; - if (ds->ops->get_sset_count) - count += ds->ops->get_sset_count(ds, dp->index, sset); + if (ds->ops->get_sset_count) { + count = ds->ops->get_sset_count(ds, dp->index, sset); + if (count < 0) + return count; + } - return count; + return count + 4; } return -EOPNOTSUPP;