From: Stefani Seibold <stefani@seibold.net>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Arnd Bergmann <arnd@arndb.de>, Andi Kleen <andi@firstfloor.org>,
Amerigo Wang <xiyou.wangcong@gmail.com>,
Joe Perches <joe@perches.com>,
Roger Quadros <quadros.roger@gmail.com>,
Greg Kroah-Hartman <gregkh@suse.de>,
Mauro Carvalho Chehab <mchehab@redhat.com>
Subject: [PATCH] kfifo: fix warn_unused_result
Date: Mon, 14 Dec 2009 06:25:51 +0100 [thread overview]
Message-ID: <1260768351.6620.57.camel@wall-e> (raw)
As requested by Andrew Morton:
This patch fix the "ignoring return value of '...', declared with
attribute warn_unused_result" compiler warning in several users of the
new kfifo API.
It removes the __must_check attribute from kfifo_in() and
kfifo_in_locked() which must not necessary performed.
Fix the allocation bug in the nozomi driver file, by moving out the
kfifo_alloc from the interrupt handler into the probe function.
Fix the kfifo_out() and kfifo_out_locked() users to handle a unexpected
end of fifo.
The patch-set is against current mm tree from 11-Dec-2009
Greetings,
Stefani
Signed-off-by: Stefani Seibold <stefani@seibold.net>
---
drivers/char/nozomi.c | 31 ++++++++++++++++++++++++----
drivers/infiniband/hw/cxgb3/cxio_resource.c | 5 ++--
drivers/media/video/meye.c | 5 ++--
drivers/net/wireless/libertas/main.c | 6 +++--
drivers/scsi/libiscsi_tcp.c | 9 ++++++--
drivers/scsi/libsrp.c | 7 ++++--
include/linux/kfifo.h | 4 +--
7 files changed, 51 insertions(+), 16 deletions(-)
diff -u -N -r mmotm.orig/include/linux/kfifo.h mmotm.new/include/linux/kfifo.h
--- mmotm.orig/include/linux/kfifo.h 2009-12-14 04:28:36.392623524 +0100
+++ mmotm.new/include/linux/kfifo.h 2009-12-14 06:15:53.889911612 +0100
@@ -110,7 +110,7 @@
extern __must_check int kfifo_alloc(struct kfifo *fifo, unsigned int size,
gfp_t gfp_mask);
extern void kfifo_free(struct kfifo *fifo);
-extern __must_check unsigned int kfifo_in(struct kfifo *fifo,
+extern unsigned int kfifo_in(struct kfifo *fifo,
const unsigned char *from, unsigned int len);
extern __must_check unsigned int kfifo_out(struct kfifo *fifo,
unsigned char *to, unsigned int len);
@@ -194,7 +194,7 @@
* the FIFO depending on the free space, and returns the number of
* bytes copied.
*/
-static inline __must_check unsigned int kfifo_in_locked(struct kfifo *fifo,
+static inline unsigned int kfifo_in_locked(struct kfifo *fifo,
const unsigned char *from, unsigned int n, spinlock_t *lock)
{
unsigned long flags;
diff -u -N -r mmotm.orig/drivers/char/nozomi.c mmotm.new/drivers/char/nozomi.c
--- mmotm.orig/drivers/char/nozomi.c 2009-12-14 04:56:54.757061915 +0100
+++ mmotm.new/drivers/char/nozomi.c 2009-12-14 06:15:53.887965205 +0100
@@ -685,8 +685,6 @@
dump_table(dc);
for (i = PORT_MDM; i < MAX_PORT; i++) {
- kfifo_alloc(&dc->port[i].fifo_ul,
- FIFO_BUFFER_SIZE_UL, GFP_ATOMIC);
memset(&dc->port[i].ctrl_dl, 0, sizeof(struct ctrl_dl));
memset(&dc->port[i].ctrl_ul, 0, sizeof(struct ctrl_ul));
}
@@ -1433,6 +1431,16 @@
goto err_free_sbuf;
}
+ for (i = PORT_MDM; i < MAX_PORT; i++) {
+ if (kfifo_alloc(&dc->port[i].fifo_ul,
+ FIFO_BUFFER_SIZE_UL, GFP_ATOMIC)) {
+ dev_err(&pdev->dev,
+ "Could not allocate kfifo buffer\n");
+ ret = -ENOMEM;
+ goto err_free_kfifo;
+ }
+ }
+
spin_lock_init(&dc->spin_mutex);
nozomi_setup_private_data(dc);
@@ -1445,7 +1453,7 @@
NOZOMI_NAME, dc);
if (unlikely(ret)) {
dev_err(&pdev->dev, "can't request irq %d\n", pdev->irq);
- goto err_free_sbuf;
+ goto err_free_kfifo;
}
DBG1("base_addr: %p", dc->base_addr);
@@ -1464,13 +1472,28 @@
dc->state = NOZOMI_STATE_ENABLED;
for (i = 0; i < MAX_PORT; i++) {
+ struct device *tty_dev;
+
mutex_init(&dc->port[i].tty_sem);
tty_port_init(&dc->port[i].port);
- tty_register_device(ntty_driver, dc->index_start + i,
+ tty_dev = tty_register_device(ntty_driver, dc->index_start + i,
&pdev->dev);
+
+ if (IS_ERR(tty_dev)) {
+ ret = PTR_ERR(tty_dev);
+ dev_err(&pdev->dev, "Could not allocate tty?\n");
+ goto err_free_tty;
+ }
}
+
return 0;
+err_free_tty:
+ for (i = dc->index_start; i < dc->index_start + MAX_PORT; ++i)
+ tty_unregister_device(ntty_driver, i);
+err_free_kfifo:
+ for (i = 0; i < MAX_PORT; i++)
+ kfifo_free(&dc->port[i].fifo_ul);
err_free_sbuf:
kfree(dc->send_buf);
iounmap(dc->base_addr);
diff -u -N -r mmotm.orig/drivers/infiniband/hw/cxgb3/cxio_resource.c mmotm.new/drivers/infiniband/hw/cxgb3/cxio_resource.c
--- mmotm.orig/drivers/infiniband/hw/cxgb3/cxio_resource.c 2009-12-14 05:48:19.409593867 +0100
+++ mmotm.new/drivers/infiniband/hw/cxgb3/cxio_resource.c 2009-12-14 06:15:53.887047560 +0100
@@ -86,8 +86,9 @@
kfifo_in(fifo, (unsigned char *) &i, sizeof(u32));
for (i = 0; i < skip_low + skip_high; i++)
- kfifo_out_locked(fifo, (unsigned char *) &entry,
- sizeof(u32), fifo_lock);
+ if (kfifo_out_locked(fifo, (unsigned char *) &entry,
+ sizeof(u32), fifo_lock) != sizeof(u32))
+ break;
return 0;
}
diff -u -N -r mmotm.orig/drivers/media/video/meye.c mmotm.new/drivers/media/video/meye.c
--- mmotm.orig/drivers/media/video/meye.c 2009-12-14 05:50:04.409843744 +0100
+++ mmotm.new/drivers/media/video/meye.c 2009-12-14 06:15:53.885580195 +0100
@@ -968,8 +968,9 @@
/* fall through */
case MEYE_BUF_DONE:
meye.grab_buffer[*i].state = MEYE_BUF_UNUSED;
- kfifo_out_locked(&meye.doneq, (unsigned char *)&unused,
- sizeof(int), &meye.doneq_lock);
+ if (kfifo_out_locked(&meye.doneq, (unsigned char *)&unused,
+ sizeof(int), &meye.doneq_lock) != sizeof(int))
+ break;
}
*i = meye.grab_buffer[*i].size;
mutex_unlock(&meye.lock);
diff -u -N -r mmotm.orig/drivers/net/wireless/libertas/main.c mmotm.new/drivers/net/wireless/libertas/main.c
--- mmotm.orig/drivers/net/wireless/libertas/main.c 2009-12-14 05:50:59.173511999 +0100
+++ mmotm.new/drivers/net/wireless/libertas/main.c 2009-12-14 06:15:53.889002627 +0100
@@ -514,8 +514,10 @@
while (kfifo_len(&priv->event_fifo)) {
u32 event;
- kfifo_out(&priv->event_fifo, (unsigned char *) &event,
- sizeof(event));
+ if (kfifo_out(&priv->event_fifo,
+ (unsigned char *) &event, sizeof(event)) !=
+ sizeof(event))
+ break;
spin_unlock_irq(&priv->driver_lock);
lbs_process_event(priv, event);
spin_lock_irq(&priv->driver_lock);
diff -u -N -r mmotm.orig/drivers/scsi/libiscsi_tcp.c mmotm.new/drivers/scsi/libiscsi_tcp.c
--- mmotm.orig/drivers/scsi/libiscsi_tcp.c 2009-12-14 05:51:36.459482982 +0100
+++ mmotm.new/drivers/scsi/libiscsi_tcp.c 2009-12-14 06:15:53.883593559 +0100
@@ -990,8 +990,13 @@
}
if (r2t == NULL) {
- kfifo_out(&tcp_task->r2tqueue,
- (void *)&tcp_task->r2t, sizeof(void *));
+ if (kfifo_out(&tcp_task->r2tqueue,
+ (void *)&tcp_task->r2t, sizeof(void *)) !=
+ sizeof(void *)) {
+ WARN_ONCE(1, "unexpected fifo state");
+ r2t = NULL;
+ }
+
r2t = tcp_task->r2t;
}
spin_unlock_bh(&session->lock);
diff -u -N -r mmotm.orig/drivers/scsi/libsrp.c mmotm.new/drivers/scsi/libsrp.c
--- mmotm.orig/drivers/scsi/libsrp.c 2009-12-14 05:51:53.838843981 +0100
+++ mmotm.new/drivers/scsi/libsrp.c 2009-12-14 06:15:53.885580195 +0100
@@ -163,8 +163,11 @@
{
struct iu_entry *iue = NULL;
- kfifo_out_locked(&target->iu_queue.queue, (void *) &iue,
- sizeof(void *), &target->iu_queue.lock);
+ if (kfifo_out_locked(&target->iu_queue.queue, (void *) &iue,
+ sizeof(void *), &target->iu_queue.lock) != sizeof(void *)) {
+ WARN_ONCE(1, "unexpected fifo state");
+ return NULL;
+ }
if (!iue)
return iue;
iue->target = target;
next reply other threads:[~2009-12-14 5:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-14 5:25 Stefani Seibold [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-12-11 9:18 [PATCH] kfifo: fix warn_unused_result Stefani Seibold
2009-12-13 22:29 ` Andrew Morton
2009-12-14 0:50 ` Alan Cox
2009-12-14 4:36 ` Stefani Seibold
2009-12-14 5:58 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1260768351.6620.57.camel@wall-e \
--to=stefani@seibold.net \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=arnd@arndb.de \
--cc=gregkh@suse.de \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@redhat.com \
--cc=quadros.roger@gmail.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.