1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/ethernet/freescale/enetc
Julia Lawall fa87c54693 net: enetc: use vmalloc_array and vcalloc
Use vmalloc_array and vcalloc to protect against
multiplication overflows.

The changes were done using the following Coccinelle
semantic patch:

// <smpl>
@initialize:ocaml@
@@

let rename alloc =
  match alloc with
    "vmalloc" -> "vmalloc_array"
  | "vzalloc" -> "vcalloc"
  | _ -> failwith "unknown"

@@
    size_t e1,e2;
    constant C1, C2;
    expression E1, E2, COUNT, x1, x2, x3;
    typedef u8;
    typedef __u8;
    type t = {u8,__u8,char,unsigned char};
    identifier alloc = {vmalloc,vzalloc};
    fresh identifier realloc = script:ocaml(alloc) { rename alloc };
@@

(
      alloc(x1*x2*x3)
|
      alloc(C1 * C2)
|
      alloc((sizeof(t)) * (COUNT), ...)
|
-     alloc((e1) * (e2))
+     realloc(e1, e2)
|
-     alloc((e1) * (COUNT))
+     realloc(COUNT, e1)
|
-     alloc((E1) * (E2))
+     realloc(E1, E2)
)
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Link: https://lore.kernel.org/r/20230627144339.144478-19-Julia.Lawall@inria.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-06-27 09:30:23 -07:00
..
enetc.c net: enetc: use vmalloc_array and vcalloc 2023-06-27 09:30:23 -07:00
enetc.h net: enetc: refactor enetc_setup_tc_taprio() to have a switch/case for cmd 2023-05-31 10:00:30 +01:00
enetc_cbdr.c net: enetc: build common object files into a separate module 2023-01-23 13:13:08 +00:00
enetc_ethtool.c net: enetc: include MAC Merge / FP registers in register dump 2023-04-20 20:03:21 -07:00
enetc_hw.h net: enetc: only commit preemptible TCs to hardware when MM TX is active 2023-04-20 20:03:21 -07:00
enetc_ierb.c net: ethernet: freescale: enetc: Drop empty platform remove function 2022-12-30 07:28:49 +00:00
enetc_ierb.h net: update NXP copyright text 2021-09-17 13:52:17 +01:00
enetc_mdio.c enetc: Separate C22 and C45 transactions 2023-01-13 21:40:54 -08:00
enetc_msg.c enetc: Add vf to pf messaging support 2019-01-24 21:55:53 -08:00
enetc_pci_mdio.c enetc: Separate C22 and C45 transactions 2023-01-13 21:40:54 -08:00
enetc_pf.c net: enetc: use lynx_pcs_create_mdiodev() 2023-05-29 21:46:53 -07:00
enetc_pf.h net: phy: lynx: refactor Lynx PCS module to use generic phylink_pcs 2022-01-02 18:48:47 +00:00
enetc_ptp.c net: enetc: Remove useless DMA-32 fallback configuration 2022-01-09 16:52:20 -08:00
enetc_qos.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-06-15 22:19:41 -07:00
enetc_vf.c net: enetc: deny offload of tc-based TSN features on VF interfaces 2022-09-20 11:27:10 -07:00
Kconfig net: ethernet: Add missing depends on MDIO_DEVRES 2023-04-12 20:38:48 -07:00
Makefile net: enetc: build common object files into a separate module 2023-01-23 13:13:08 +00:00