diff options
-rw-r--r-- | drivers/target/target_core_transport.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 20ab27cb3e45..67d4286cf244 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -4357,11 +4357,9 @@ transport_generic_get_mem(struct se_cmd *cmd, u32 length, u32 dma_size) | |||
4357 | printk(KERN_ERR "Unable to allocate struct se_mem\n"); | 4357 | printk(KERN_ERR "Unable to allocate struct se_mem\n"); |
4358 | goto out; | 4358 | goto out; |
4359 | } | 4359 | } |
4360 | INIT_LIST_HEAD(&se_mem->se_list); | ||
4361 | se_mem->se_len = (length > dma_size) ? dma_size : length; | ||
4362 | 4360 | ||
4363 | /* #warning FIXME Allocate contigous pages for struct se_mem elements */ | 4361 | /* #warning FIXME Allocate contigous pages for struct se_mem elements */ |
4364 | se_mem->se_page = (struct page *) alloc_pages(GFP_KERNEL, 0); | 4362 | se_mem->se_page = alloc_pages(GFP_KERNEL, 0); |
4365 | if (!(se_mem->se_page)) { | 4363 | if (!(se_mem->se_page)) { |
4366 | printk(KERN_ERR "alloc_pages() failed\n"); | 4364 | printk(KERN_ERR "alloc_pages() failed\n"); |
4367 | goto out; | 4365 | goto out; |
@@ -4372,6 +4370,8 @@ transport_generic_get_mem(struct se_cmd *cmd, u32 length, u32 dma_size) | |||
4372 | printk(KERN_ERR "kmap_atomic() failed\n"); | 4370 | printk(KERN_ERR "kmap_atomic() failed\n"); |
4373 | goto out; | 4371 | goto out; |
4374 | } | 4372 | } |
4373 | INIT_LIST_HEAD(&se_mem->se_list); | ||
4374 | se_mem->se_len = (length > dma_size) ? dma_size : length; | ||
4375 | memset(buf, 0, se_mem->se_len); | 4375 | memset(buf, 0, se_mem->se_len); |
4376 | kunmap_atomic(buf, KM_IRQ0); | 4376 | kunmap_atomic(buf, KM_IRQ0); |
4377 | 4377 | ||
@@ -4390,6 +4390,9 @@ transport_generic_get_mem(struct se_cmd *cmd, u32 length, u32 dma_size) | |||
4390 | 4390 | ||
4391 | return 0; | 4391 | return 0; |
4392 | out: | 4392 | out: |
4393 | if (se_mem) | ||
4394 | __free_pages(se_mem->se_page, 0); | ||
4395 | kmem_cache_free(se_mem_cache, se_mem); | ||
4393 | return -1; | 4396 | return -1; |
4394 | } | 4397 | } |
4395 | 4398 | ||