mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] wusb: fix find_first_zero_bit() return value check
@ 2011-03-02 11:35 Akinobu Mita
  0 siblings, 0 replies; only message in thread
From: Akinobu Mita @ 2011-03-02 11:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Akinobu Mita, linux-usb, Greg Kroah-Hartman

In wusb_cluster_id_get(), if no zero bits exist in wusb_cluster_id_table,
find_first_zero_bit() returns CLUSTER_IDS.

But it is impossible to detect that the bitmap is full because there
is an off-by-one error in the return value check.  It will cause
unexpected memory access by setting bit out of wusb_cluster_id_table
bitmap, and caller will get wrong cluster id.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: linux-usb@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/usb/wusbcore/wusbhc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/wusbcore/wusbhc.c b/drivers/usb/wusbcore/wusbhc.c
index 2054d4e..0faca16 100644
--- a/drivers/usb/wusbcore/wusbhc.c
+++ b/drivers/usb/wusbcore/wusbhc.c
@@ -320,7 +320,7 @@ u8 wusb_cluster_id_get(void)
 	u8 id;
 	spin_lock(&wusb_cluster_ids_lock);
 	id = find_first_zero_bit(wusb_cluster_id_table, CLUSTER_IDS);
-	if (id > CLUSTER_IDS) {
+	if (id >= CLUSTER_IDS) {
 		id = 0;
 		goto out;
 	}
-- 
1.7.4


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-03-02 11:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-02 11:35 [PATCH] wusb: fix find_first_zero_bit() return value check Akinobu Mita

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®