diff options
author | Kees Cook <[email protected]> | 2023-08-17 16:58:58 -0700 |
---|---|---|
committer | Vinod Koul <[email protected]> | 2023-09-28 16:42:16 +0530 |
commit | a04bbeaa37d8789de5592506fa776256e784b69c (patch) | |
tree | 7cd63b6f0cc627efe369f4dd5487f429e1b10a7c | |
parent | 7935de861aed45f97a4262d9b215d9feb172516b (diff) |
dmaengine: usb-dmac: Annotate struct usb_dmac_desc with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).
As found with Coccinelle[1], add __counted_by for struct usb_dmac_desc.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc: Vinod Koul <[email protected]>
Cc: Yu Kuai <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Jordy Zomer <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Tudor Ambarus <[email protected]>
Cc: [email protected]
Signed-off-by: Kees Cook <[email protected]>
Reviewed-by: "Gustavo A. R. Silva" <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Vinod Koul <[email protected]>
-rw-r--r-- | drivers/dma/sh/usb-dmac.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c index d8c93faa424d..a9b4302f6050 100644 --- a/drivers/dma/sh/usb-dmac.c +++ b/drivers/dma/sh/usb-dmac.c @@ -57,7 +57,7 @@ struct usb_dmac_desc { u32 residue; struct list_head node; dma_cookie_t done_cookie; - struct usb_dmac_sg sg[]; + struct usb_dmac_sg sg[] __counted_by(sg_allocated_len); }; #define to_usb_dmac_desc(vd) container_of(vd, struct usb_dmac_desc, vd) |