]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
USB: serial: garmin_gps: annotate struct garmin_packet with __counted_by
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Wed, 19 Jun 2024 19:42:44 +0000 (21:42 +0200)
committerJohan Hovold <johan@kernel.org>
Fri, 5 Jul 2024 12:00:11 +0000 (14:00 +0200)
Use the __counted_by compiler attribute for the data[] flexible array
member to improve the results of array bound sanitizers.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
drivers/usb/serial/garmin_gps.c

index 670e942fdaaa18d93b223f23640dbef5594da22e..57df6ad183ff03c53a224d6322cd8979ea26e2f1 100644 (file)
@@ -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 */