From: Javier Carrasco Date: Wed, 19 Jun 2024 19:42:44 +0000 (+0200) Subject: USB: serial: garmin_gps: annotate struct garmin_packet with __counted_by X-Git-Tag: v6.11-rc3~4^2~15^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=55a15b3a713a3f24360cf9d8dcfd2a3e337321d6;p=thirdparty%2Fkernel%2Flinux.git USB: serial: garmin_gps: annotate struct garmin_packet with __counted_by Use the __counted_by compiler attribute for the data[] flexible array member to improve the results of array bound sanitizers. Reviewed-by: Nathan Chancellor Signed-off-by: Javier Carrasco Reviewed-by: Gustavo A. R. Silva Reviewed-by: Kees Cook Signed-off-by: Johan Hovold --- diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 670e942fdaaa1..57df6ad183ff0 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -104,7 +104,7 @@ struct garmin_packet { int seq; /* the real size of the data array, always > 0 */ int size; - __u8 data[]; + __u8 data[] __counted_by(size); }; /* structure used to keep the current state of the driver */