1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/ethernet/amd/pds_core
Julia Lawall 906a76cc76 pds_core: 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-10-Julia.Lawall@inria.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-06-27 09:30:23 -07:00
..
adminq.c pds_core: publish events to the clients 2023-04-21 08:29:13 +01:00
auxbus.c pds_core: add the aux client API 2023-04-21 08:29:13 +01:00
core.c pds_core: use vmalloc_array and vcalloc 2023-06-27 09:30:23 -07:00
core.h pds_core: publish events to the clients 2023-04-21 08:29:13 +01:00
debugfs.c pds_core: set up the VIF definitions and defaults 2023-04-21 08:29:13 +01:00
dev.c pds_core: Fix FW recovery detection 2023-06-06 21:10:01 -07:00
devlink.c pds_core: devlink params for enabling VIF support 2023-04-21 08:29:13 +01:00
fw.c pds_core: add FW update feature to devlink 2023-04-21 08:29:13 +01:00
main.c pds_core: fix mutex double unlock in error path 2023-05-05 10:02:47 +01:00
Makefile pds_core: remove CONFIG_DEBUG_FS from makefile 2023-05-03 09:15:50 +01:00