diff options
author | Roel Kluin <roel.kluin@gmail.com> | 2009-08-22 13:32:44 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-15 15:02:29 -0400 |
commit | 48c8276d7ac534d62c594c9a493130ff9137675d (patch) | |
tree | f7634439718ce421401e2160bf98b7093b1a5138 /drivers | |
parent | 77943d31b7dfdbd1ad58d49bd16ae6e7601bcd6c (diff) |
Staging: rspiusb: Check usb_buffer_map_sg() retval
usb_buffer_map_sg() may return -1, check this directly.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Reviewed-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/rspiusb/rspiusb.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/staging/rspiusb/rspiusb.c b/drivers/staging/rspiusb/rspiusb.c index 04e2f92c0f62..0495fbfe59d9 100644 --- a/drivers/staging/rspiusb/rspiusb.c +++ b/drivers/staging/rspiusb/rspiusb.c | |||
@@ -611,6 +611,7 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx) | |||
611 | int i = 0; | 611 | int i = 0; |
612 | int k = 0; | 612 | int k = 0; |
613 | int err = 0; | 613 | int err = 0; |
614 | int ret; | ||
614 | struct page **maplist_p; | 615 | struct page **maplist_p; |
615 | int numPagesRequired; | 616 | int numPagesRequired; |
616 | 617 | ||
@@ -687,9 +688,16 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx) | |||
687 | } else { | 688 | } else { |
688 | pdx->sgl[frameInfo][0].length = count; | 689 | pdx->sgl[frameInfo][0].length = count; |
689 | } | 690 | } |
690 | pdx->sgEntries[frameInfo] = | 691 | ret = usb_buffer_map_sg(pdx->udev, epAddr, pdx->sgl[frameInfo], |
691 | usb_buffer_map_sg(pdx->udev, epAddr, pdx->sgl[frameInfo], | 692 | pdx->maplist_numPagesMapped[frameInfo]); |
692 | pdx->maplist_numPagesMapped[frameInfo]); | 693 | if (ret < 0) { |
694 | vfree(maplist_p); | ||
695 | dbg("usb_buffer_map_sg() failed"); | ||
696 | return -EINVAL; | ||
697 | } | ||
698 | |||
699 | pdx->sgEntries[frameInfo] = ret; | ||
700 | |||
693 | dbg("number of sgEntries = %d", pdx->sgEntries[frameInfo]); | 701 | dbg("number of sgEntries = %d", pdx->sgEntries[frameInfo]); |
694 | pdx->userBufMapped = 1; | 702 | pdx->userBufMapped = 1; |
695 | vfree(maplist_p); | 703 | vfree(maplist_p); |
@@ -716,8 +724,6 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx) | |||
716 | pdx->PixelUrb[frameInfo][i]->transfer_flags = | 724 | pdx->PixelUrb[frameInfo][i]->transfer_flags = |
717 | URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; | 725 | URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; |
718 | } | 726 | } |
719 | if (i == 0) | ||
720 | return -EINVAL; | ||
721 | /* only interrupt when last URB completes */ | 727 | /* only interrupt when last URB completes */ |
722 | pdx->PixelUrb[frameInfo][--i]->transfer_flags &= ~URB_NO_INTERRUPT; | 728 | pdx->PixelUrb[frameInfo][--i]->transfer_flags &= ~URB_NO_INTERRUPT; |
723 | pdx->pendedPixelUrbs[frameInfo] = | 729 | pdx->pendedPixelUrbs[frameInfo] = |