]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - lib/scatterlist.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
[karo-tx-linux.git] / lib / scatterlist.c
index 129a82f707df9b08d7c8e777561fca30c579816c..a685c8a79578b274cb361d442b953507e58d7d63 100644 (file)
@@ -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 {