From: Vladimir Oltean <vladimir.olt...@nxp.com> Currently, this function would check the port_egress_floods pointer only in the preparation phase, the assumption being that the caller wouldn't proceed to a second call since it returned -EOPNOTSUPP. If the function were to be called a second time though, the port_egress_floods pointer would not be checked and the driver would proceed to dereference it.
Signed-off-by: Vladimir Oltean <vladimir.olt...@nxp.com> --- net/dsa/port.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/dsa/port.c b/net/dsa/port.c index e23ece229c7e..c4032f79225a 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -324,8 +324,11 @@ int dsa_port_mrouter(struct dsa_port *dp, bool mrouter, struct dsa_switch *ds = dp->ds; int port = dp->index; + if (!ds->ops->port_egress_floods) + return -EOPNOTSUPP; + if (switchdev_trans_ph_prepare(trans)) - return ds->ops->port_egress_floods ? 0 : -EOPNOTSUPP; + return 0; return ds->ops->port_egress_floods(ds, port, true, mrouter); } -- 2.25.1