X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=lib%2Fscatterlist.c;h=a685c8a79578b274cb361d442b953507e58d7d63;hb=72c1c2f1be6b6574c434bd60991269786c2431a2;hp=129a82f707df9b08d7c8e777561fca30c579816c;hpb=df642cea25c90dc7d5dcd9d3b480b6b59de7d787;p=~andy%2Flinux diff --git a/lib/scatterlist.c b/lib/scatterlist.c index 129a82f707d..a685c8a7957 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 {