USB: FHCI: cq_get() should check kfifo_out()'s return value
PATCH 1/1 USB: FHCI: cq_get() should check kfifo_out()'s return value
Since commit 7acd72eb85f1c7a15e8b5eb554994949241737f1 ("kfifo: rename kfifo_put... into kfifo_in... and kfifo_get... into kfifo_out..."), kfifo_out() is marked __must_check, and that causes gcc to produce lots of warnings like this:
CC drivers/usb/host/fhci-mem.o
In file included from drivers/usb/host/fhci-hcd.c:34:drivers/usb/host/fhci.h: In function 'cq_get':drivers/usb/host/fhci.h:520: warning: ignoring return value of 'kfifo_out', declared with attribute warn_unused_result
...
Fix it with BUG_ON() check. We could just forcibly ignore return value, but it's better to check if we really got a whole pointer.
--- drivers/usb/host/fhci.h | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/usb/host/fhci.h +5 -1
@@ -20,6 +20,7 @@#include <linux/kernel.h> #include <linux/types.h> +#include <linux/bug.h> #include <linux/spinlock.h> #include <linux/interrupt.h> #include <linux/kfifo.h>
@@ -515,9 +516,12 @@ static inline int cq_put(struct kfifo *kfifo, void *p)static inline void *cq_get (struct kfifo *kfifo) { +unsigned int sz;void *p =NULL ; -kfifo_out (kfifo, (void *)&p,sizeof (p)); + sz =kfifo_out (kfifo, (void *)&p,sizeof (p)); +BUG_ON (sz !=sizeof (p)); +return p; }
Signature · 1 line
1.7.0.5
Quoted 5 lines · Anton Vorontsov
Since commit
7acd72eb85f1c7a15e8b5eb554994949241737f1("kfifo: renamekfifo_put... intokfifo_in... andkfifo_get... intokfifo_out..."),kfifo_out()is marked__must_check, and that causes gcc to produce lots of warnings like this:
Quoted 8 lines
CC
drivers/usb/host/fhci-mem.o
In file included fromdrivers/usb/host/fhci-hcd.c:34:drivers/usb/host/fhci.h: In function 'cq_get':drivers/usb/host/fhci.h:520: warning: ignoring return value of 'kfifo_out', declared with attributewarn_unused_result
...Fix it with
BUG_ON()check. We could just forcibly ignore return value, but it's better to check if we really got a whole pointer.
No, you don't want to crash the whole machine for something like this.
Please just handle the error normally and pass it up to the upper levels if possible.
thanks,
greg k-h