Skip to content

Commit

Permalink
USB: fix oops in usb_sg_init()
Browse files Browse the repository at this point in the history
This patch (as1401) fixes a bug in usb_sg_init() that can cause an
invalid pointer dereference.  An inner loop reuses some local variables
in an unsafe manner, so new variables are introduced.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Jun 30, 2010
1 parent 3b49d23 commit 64d6587
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/usb/core/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,11 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
/* A length of zero means transfer the whole sg list */
len = length;
if (len == 0) {
for_each_sg(sg, sg, nents, i)
len += sg->length;
struct scatterlist *sg2;
int j;

for_each_sg(sg, sg2, nents, j)
len += sg2->length;
}
} else {
/*
Expand Down

0 comments on commit 64d6587

Please sign in to comment.