Commit cc537af9 authored by Christoph Hellwig's avatar Christoph Hellwig

[XFS] Fix buffer teardown on _pagebuf_lookup_pages failure

SGI Modid: xfs-linux:xfs-kern:166032a
parent b426ad96
...@@ -779,8 +779,9 @@ pagebuf_get( /* allocate a buffer */ ...@@ -779,8 +779,9 @@ pagebuf_get( /* allocate a buffer */
/* fill in any missing pages */ /* fill in any missing pages */
error = _pagebuf_lookup_pages(pb, pb->pb_target->pbr_mapping, flags); error = _pagebuf_lookup_pages(pb, pb->pb_target->pbr_mapping, flags);
if (unlikely(error)) { if (unlikely(error)) {
pagebuf_free(pb); printk(KERN_WARNING
return (NULL); "pagebuf_get: warning, failed to lookup pages\n");
goto no_buffer;
} }
/* /*
...@@ -801,10 +802,7 @@ pagebuf_get( /* allocate a buffer */ ...@@ -801,10 +802,7 @@ pagebuf_get( /* allocate a buffer */
* Read ahead call which is already satisfied, * Read ahead call which is already satisfied,
* drop the buffer * drop the buffer
*/ */
if (flags & (PBF_LOCK | PBF_TRYLOCK)) goto no_buffer;
pagebuf_unlock(pb);
pagebuf_rele(pb);
return NULL;
} else { } else {
PB_TRACE(pb, "get_read_done", (unsigned long)flags); PB_TRACE(pb, "get_read_done", (unsigned long)flags);
/* We do not want read in the flags */ /* We do not want read in the flags */
...@@ -813,7 +811,14 @@ pagebuf_get( /* allocate a buffer */ ...@@ -813,7 +811,14 @@ pagebuf_get( /* allocate a buffer */
} else { } else {
PB_TRACE(pb, "get_write", (unsigned long)flags); PB_TRACE(pb, "get_write", (unsigned long)flags);
} }
return (pb);
return pb;
no_buffer:
if (flags & (PBF_LOCK | PBF_TRYLOCK))
pagebuf_unlock(pb);
pagebuf_rele(pb);
return NULL;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment