summaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorBart Van Assche <bart.vanassche@sandisk.com>2016-01-05 14:47:17 +0100
committerNicholas Bellinger <nab@linux-iscsi.org>2016-01-07 13:57:55 -0800
commitf0a8afecb29ad0005e7e946228a0ef5422058b85 (patch)
treeeaf1eb68b8c884bd70ac40e648488b48e366ba50 /drivers/target
parent5261d86c5ce5726f097ed5e4ea28c40684ebf8e4 (diff)
downloadop-kernel-dev-f0a8afecb29ad0005e7e946228a0ef5422058b85.zip
op-kernel-dev-f0a8afecb29ad0005e7e946228a0ef5422058b85.tar.gz
target: Fix a memory leak in target_dev_lba_map_store()
strsep() modifies its first argument. Make the pointer passed to kfree() match the return value of kmalloc(). Fixes: 229d4f112fd6 (commit "target_core_alua: Referrals configfs integration") Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Cc: Hannes Reinecke <hare@suse.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Andy Grover <agrover@redhat.com> Cc: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_configfs.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 9ef0893..3327c49 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -2017,14 +2017,14 @@ static ssize_t target_dev_lba_map_store(struct config_item *item,
struct se_device *dev = to_device(item);
struct t10_alua_lba_map *lba_map = NULL;
struct list_head lba_list;
- char *map_entries, *ptr;
+ char *map_entries, *orig, *ptr;
char state;
int pg_num = -1, pg;
int ret = 0, num = 0, pg_id, alua_state;
unsigned long start_lba = -1, end_lba = -1;
unsigned long segment_size = -1, segment_mult = -1;
- map_entries = kstrdup(page, GFP_KERNEL);
+ orig = map_entries = kstrdup(page, GFP_KERNEL);
if (!map_entries)
return -ENOMEM;
@@ -2122,7 +2122,7 @@ out:
} else
core_alua_set_lba_map(dev, &lba_list,
segment_size, segment_mult);
- kfree(map_entries);
+ kfree(orig);
return count;
}
OpenPOWER on IntegriCloud