[PATCH v1 3/5] j1939: bus: warn if we trying to map already mapped ECU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



better to know if we do wrong mapping, instead of silently "fix" it
on this place.

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




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux