+ lib-scatterlist-error-handling-in-__sg_alloc_table.patch added to -mm tree
[email protected]
maintainerSubject: + lib-scatterlist-error-handling-in-__sg_alloc_table.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Wed, 26 Jun 2013 14:33:01 -0700
The patch titled
Subject: lib/scatterlist: error handling in __sg_alloc_table()
has been added to the -mm tree. Its filename is
lib-scatterlist-error-handling-in-__sg_alloc_table.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Dan Carpenter <[email protected]>
Subject: lib/scatterlist: error handling in __sg_alloc_table()
I was reviewing code which I suspected might allocate a zero size SG table. That will cause memory corruption. Also we can't return before doing the memset or we could end up using uninitialized memory in the cleanup path.
---
lib/scatterlist.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
lib/scatterlist.c renamed from lib/scatterlist.c~lib-scatterlist-error-handling-in-__sg_alloc_table +4 -1
@@ -247,13 +247,15 @@ int __sg_alloc_table(struct sg_table *tastruct 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));