linux/drivers/net/ethernet/freescale
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
..
dpaa Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-04-26 10:17:46 +02:00
dpaa2 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-06-22 18:40:38 -07:00
enetc net: enetc: use vmalloc_array and vcalloc 2023-06-27 09:30:23 -07:00
fman net: phylink: pass neg_mode into phylink_mii_c22_pcs_config() 2023-06-22 19:41:01 -07:00
fs_enet eth: fs_enet: fix print format for resource size 2023-06-15 22:54:06 -07:00
fec.h net: fec: make use of MDIO C45 quirk 2023-04-05 18:58:30 -07:00
fec_main.c net: fec: allow to build without PAGE_POOL_STATS 2023-06-20 12:11:59 -07:00
fec_mpc52xx.c net: Use of_property_read_bool() for boolean properties 2023-03-16 17:41:28 +00:00
fec_mpc52xx.h
fec_mpc52xx_phy.c
fec_ptp.c ptp: convert remaining drivers to adjfine interface 2022-11-11 10:58:39 +00:00
fsl_pq_mdio.c
gianfar.c net: Use of_property_read_bool() for boolean properties 2023-03-16 17:41:28 +00:00
gianfar.h
gianfar_ethtool.c net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
Kconfig net: fec: allow to build without PAGE_POOL_STATS 2023-06-20 12:11:59 -07:00
Makefile
ucc_geth.c net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
ucc_geth.h
ucc_geth_ethtool.c net: ethernet: move from strlcpy with unused retval to strscpy 2022-08-31 14:11:26 -07:00
xgmac_mdio.c net: phy: Remove probe_capabilities 2023-01-19 16:23:19 +01:00