linux-stable/drivers/infiniband/hw/erdma
Julia Lawall c619af8327 RDMA/erdma: 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>

Link: https://lore.kernel.org/r/20230627144339.144478-6-Julia.Lawall@inria.fr
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
2023-07-21 15:51:58 -03:00
..
erdma.h RDMA/erdma: Refactor the original doorbell allocation mechanism 2023-06-11 11:57:01 +03:00
erdma_cm.c net/sock: Introduce trace_sk_data_ready() 2023-01-23 11:26:50 +00:00
erdma_cm.h RDMA/erdma: Unify byte ordering APIs usage 2023-03-22 13:10:46 +02:00
erdma_cmdq.c RDMA/erdma: Minor refactor of device init flow 2023-03-22 13:10:46 +02:00
erdma_cq.c v6.4 merge window RDMA pull request 2023-04-29 17:21:24 -07:00
erdma_eq.c RDMA/erdma: Eliminate unnecessary casting of EQ doorbells 2023-03-22 13:10:46 +02:00
erdma_hw.h RDMA/erdma: Refactor the original doorbell allocation mechanism 2023-06-11 11:57:01 +03:00
erdma_main.c RDMA/erdma: Refactor the original doorbell allocation mechanism 2023-06-11 11:57:01 +03:00
erdma_qp.c RDMA/erdma: Inline mtt entries into WQE if supported 2023-03-20 12:53:24 +02:00
erdma_verbs.c RDMA/erdma: use vmalloc_array and vcalloc 2023-07-21 15:51:58 -03:00
erdma_verbs.h RDMA/erdma: Refactor the original doorbell allocation mechanism 2023-06-11 11:57:01 +03:00
Kconfig RDMA/erdma: Add driver to kernel build environment 2022-07-27 16:04:05 -03:00
Makefile RDMA/erdma: Add driver to kernel build environment 2022-07-27 16:04:05 -03:00