207-dcdp-atm_tc-fix-crash-on-subif_reg-absence.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From: Sergey Ryazanov <[email protected]>
  2. Date: Fri, 10 Jan 2025 00:57:27 +0000
  3. Subject: [PATCH] vrx518_tc: atm_tc: fix crash on subif_reg absence
  4. VRX518 (sw_plat) platform does not provid the subif_reg/subif_unreg ops
  5. in the same time ATM TC layer unconditionally calls them, what leads to
  6. the kernel crash on the atm_hook_mpoa_setup hook invocation from the ATM
  7. stack:
  8. vrx518_tc:mpoa_setup_sync : sync: conn: 0, vpi: 0, vci: 35, mpoa_type: 0, mpoa_mode: 0
  9. Unable to handle kernel NULL pointer dereference at virtual address 00000000
  10. Subif registration is optional and PTM TC do this only when the
  11. corresponding ops are defined. Do the same for ATM TC and call
  12. subif_reg/subif_unreg only if they are not NULL.
  13. While at it, move subif related data preparation under the 'if' block
  14. in order to group and isolate that aux code.
  15. Run tested with FRITZ!Box 7530.
  16. Signed-off-by: Sergey Ryazanov <[email protected]>
  17. ---
  18. --- a/dcdp/atm_tc.c
  19. +++ b/dcdp/atm_tc.c
  20. @@ -1158,8 +1158,9 @@ static void ppe_close(struct atm_vcc *vc
  21. validate_oam_htu_entry(priv, 0);
  22. spin_unlock_bh(&priv->atm_lock);
  23. - priv->tc_priv->tc_ops.subif_unreg(dev, (!dev) ? dev_name : dev->name,
  24. - priv->conn[cid].subif_id, 0);
  25. + if (priv->tc_priv->tc_ops.subif_unreg)
  26. + priv->tc_priv->tc_ops.subif_unreg(dev, (!dev) ? dev_name : dev->name,
  27. + priv->conn[cid].subif_id, 0);
  28. memset(conn, 0, sizeof(*conn));
  29. @@ -2710,24 +2711,26 @@ static void mpoa_setup_sync(struct atm_p
  30. struct wtx_queue_config_t tx_qcfg;
  31. struct uni_cell_header *cell_header;
  32. struct atm_vcc *vcc;
  33. - struct net_device *dev;
  34. - char dev_name[32];
  35. tc_dbg(priv->tc_priv, MSG_INIT,
  36. "sync: conn: %d, vpi: %d, vci: %d, mpoa_type: %d, mpoa_mode: %d\n",
  37. conn, priv->conn[conn].vcc->vpi, priv->conn[conn].vcc->vci,
  38. priv->conn[conn].mpoa_type, priv->conn[conn].mpoa_mode);
  39. - dev = priv->conn[conn].dev;
  40. + if (priv->tc_priv->tc_ops.subif_reg) {
  41. + struct net_device *dev;
  42. + char dev_name[32];
  43. +
  44. + dev = priv->conn[conn].dev;
  45. + if (!dev)
  46. + sprintf(dev_name, "atm_%d%d",
  47. + priv->conn[conn].vcc->vpi, priv->conn[conn].vcc->vci);
  48. - if (!dev)
  49. - sprintf(dev_name, "atm_%d%d",
  50. - priv->conn[conn].vcc->vpi, priv->conn[conn].vcc->vci);
  51. -
  52. - priv->tc_priv->tc_ops.subif_reg(dev, (!dev) ? dev_name : dev->name,
  53. - &priv->conn[conn].subif_id, 0);
  54. - tc_dbg(priv->tc_priv, MSG_INIT,
  55. - "conn[%d]subif_id[%x]", conn, priv->conn[conn].subif_id);
  56. + priv->tc_priv->tc_ops.subif_reg(dev, !dev ? dev_name : dev->name,
  57. + &priv->conn[conn].subif_id, 0);
  58. + tc_dbg(priv->tc_priv, MSG_INIT,
  59. + "conn[%d]subif_id[%x]", conn, priv->conn[conn].subif_id);
  60. + }
  61. vcc = priv->conn[conn].vcc;
  62. /* set htu entry */