author: Dan Carpenter <dan.carpenter@oracle.com> 2013-07-08 16:01:58 -0700
committer: Linus Torvalds <torvalds@linux-foundation.org> 2013-07-09 10:33:31 -0700
commit: 27daabd9b6a157c34a6e7a7f509fa26866e6420f
parent: a451751172b39702e94c683882ab01d816b673c7
Commit Summary:
Diffstat:
1 file changed, 3 insertions, 2 deletions
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 129a82f707df..a685c8a79578 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -247,13 +247,15 @@ int __sg_alloc_table(struct sg_table *table, unsigned int nents,
struct scatterlist *sg, *prv;
unsigned int left;
+ memset(table, 0, sizeof(*table));
+
+ if (nents == 0)
+ return -EINVAL;
#ifndef ARCH_HAS_SG_CHAIN
if (WARN_ON_ONCE(nents > max_ents))
return -EINVAL;
#endif
- memset(table, 0, sizeof(*table));
-
left = nents;
prv = NULL;
do {