All of lore.kernel.org
 help / color / mirror / Atom feed
* + lib-scatterlist-error-handling-in-__sg_alloc_table.patch added to -mm tree
@ 2013-06-26 21:33 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2013-06-26 21:33 UTC (permalink / raw)
  To: mm-commits, tj, maximlevitsky, imre.deak, daniel.vetter,
	akinobu.mita, dan.carpenter

Subject: + lib-scatterlist-error-handling-in-__sg_alloc_table.patch added to -mm tree
To: dan.carpenter@oracle.com,akinobu.mita@gmail.com,daniel.vetter@ffwll.ch,imre.deak@intel.com,maximlevitsky@gmail.com,tj@kernel.org
From: akpm@linux-foundation.org
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 <dan.carpenter@oracle.com>
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.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 lib/scatterlist.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff -puN lib/scatterlist.c~lib-scatterlist-error-handling-in-__sg_alloc_table lib/scatterlist.c
--- a/lib/scatterlist.c~lib-scatterlist-error-handling-in-__sg_alloc_table
+++ a/lib/scatterlist.c
@@ -247,13 +247,15 @@ int __sg_alloc_table(struct sg_table *ta
 	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));

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-06-26 21:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-26 21:33 + lib-scatterlist-error-handling-in-__sg_alloc_table.patch added to -mm tree akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.