On Fri, Nov 02, 2018 at 07:42:35PM +0100, Kurt Van Dijck wrote: > On vr, 02 nov 2018 12:32:20 +0100, Oleksij Rempel wrote: > > > > better to know if we do wrong mapping, instead of silently "fix" it > > on this place. > > Do we agree that this 'should not occur'? correct. > This is a workaround for a deeper problem, shouldn't we attach the > deeper problem? It is not a workaround, we should be notified if some code makes wrong things. The fix for this cases is in: [PATCH v1 4/5] j1939: address-claim: handle ECU reclaiming as a new claim. > > > > Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> > > --- > > net/can/j1939/bus.c | 15 +++++++++++++-- > > 1 file changed, 13 insertions(+), 2 deletions(-) > > > > diff --git a/net/can/j1939/bus.c b/net/can/j1939/bus.c > > index 171fbdb2a1a8..9ebaa497139b 100644 > > --- a/net/can/j1939/bus.c > > +++ b/net/can/j1939/bus.c > > @@ -51,14 +51,25 @@ static bool j1939_ecu_is_mapped_locked(struct j1939_ecu *ecu) > > /* map ECU to a bus address space */ > > static void j1939_ecu_map_locked(struct j1939_ecu *ecu) > > { > > + struct j1939_priv *priv = ecu->priv; > > + struct j1939_addr_ent *ent; > > + > > lockdep_assert_held(&ecu->priv->lock); > > > > if (!j1939_address_is_unicast(ecu->addr)) > > return; > > > > + ent = &ecu->priv->ents[ecu->addr]; > > + > > + if (ent->ecu) { > > + netdev_warn(priv->ndev, "Trying to map already mapped ECU, addr: 0x%02x, name: 0x%016llx. Skip it.\n", > > + ecu->addr, ecu->name); > > + return; > > + } > > + > > j1939_ecu_get(ecu); > > - ecu->priv->ents[ecu->addr].ecu = ecu; > > - ecu->priv->ents[ecu->addr].nusers += ecu->nusers; > > + ent->ecu = ecu; > > + ent->nusers += ecu->nusers; > > } > > > > /* unmap ECU from a bus address space */ > > -- > > 2.19.1 > > > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |