aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/scatterlist.c6
1 files changed, 4 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,
247 struct scatterlist *sg, *prv; 247 struct scatterlist *sg, *prv;
248 unsigned int left; 248 unsigned int left;
249 249
250 memset(table, 0, sizeof(*table));
251
252 if (nents == 0)
253 return -EINVAL;
250#ifndef ARCH_HAS_SG_CHAIN 254#ifndef ARCH_HAS_SG_CHAIN
251 if (WARN_ON_ONCE(nents > max_ents)) 255 if (WARN_ON_ONCE(nents > max_ents))
252 return -EINVAL; 256 return -EINVAL;
253#endif 257#endif
254 258
255 memset(table, 0, sizeof(*table));
256
257 left = nents; 259 left = nents;
258 prv = NULL; 260 prv = NULL;
259 do { 261 do {