summaryrefslogtreecommitdiffstats
path: root/lib/scatterlist.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2010-09-16 07:33:21 +0200
committerTakashi Iwai <tiwai@suse.de>2010-09-16 07:33:21 +0200
commitc91925db4925ba0d145478f02c093369196936e9 (patch)
tree0e5da4211de3c18b65337c3094ec15994cf2534a /lib/scatterlist.c
parent977ddd6b2e63716cfefe669bbdb30ec0bcea1fe4 (diff)
parent3894335876a6257ac46e14845bd37ae6fb0f7c87 (diff)
downloadlinux-c91925db4925ba0d145478f02c093369196936e9.tar.gz
linux-c91925db4925ba0d145478f02c093369196936e9.tar.bz2
linux-c91925db4925ba0d145478f02c093369196936e9.zip
Merge branch 'fix/hda' into topic/hda
Diffstat (limited to 'lib/scatterlist.c')
-rw-r--r--lib/scatterlist.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index a5ec42868f99..4ceb05d772ae 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -248,8 +248,18 @@ int __sg_alloc_table(struct sg_table *table, unsigned int nents,
left -= sg_size;
sg = alloc_fn(alloc_size, gfp_mask);
- if (unlikely(!sg))
- return -ENOMEM;
+ if (unlikely(!sg)) {
+ /*
+ * Adjust entry count to reflect that the last
+ * entry of the previous table won't be used for
+ * linkage. Without this, sg_kfree() may get
+ * confused.
+ */
+ if (prv)
+ table->nents = ++table->orig_nents;
+
+ return -ENOMEM;
+ }
sg_init_table(sg, alloc_size);
table->nents = table->orig_nents += sg_size;