diff options
author | Bart Van Assche <bart.vanassche@sandisk.com> | 2016-01-05 08:47:17 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2016-01-07 16:57:55 -0500 |
commit | f0a8afecb29ad0005e7e946228a0ef5422058b85 (patch) | |
tree | eaf1eb68b8c884bd70ac40e648488b48e366ba50 /drivers/target/target_core_configfs.c | |
parent | 5261d86c5ce5726f097ed5e4ea28c40684ebf8e4 (diff) |
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/target_core_configfs.c')
-rw-r--r-- | drivers/target/target_core_configfs.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 9ef08930a556..3327c49674d3 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, | |||
2017 | struct se_device *dev = to_device(item); | 2017 | struct se_device *dev = to_device(item); |
2018 | struct t10_alua_lba_map *lba_map = NULL; | 2018 | struct t10_alua_lba_map *lba_map = NULL; |
2019 | struct list_head lba_list; | 2019 | struct list_head lba_list; |
2020 | char *map_entries, *ptr; | 2020 | char *map_entries, *orig, *ptr; |
2021 | char state; | 2021 | char state; |
2022 | int pg_num = -1, pg; | 2022 | int pg_num = -1, pg; |
2023 | int ret = 0, num = 0, pg_id, alua_state; | 2023 | int ret = 0, num = 0, pg_id, alua_state; |
2024 | unsigned long start_lba = -1, end_lba = -1; | 2024 | unsigned long start_lba = -1, end_lba = -1; |
2025 | unsigned long segment_size = -1, segment_mult = -1; | 2025 | unsigned long segment_size = -1, segment_mult = -1; |
2026 | 2026 | ||
2027 | map_entries = kstrdup(page, GFP_KERNEL); | 2027 | orig = map_entries = kstrdup(page, GFP_KERNEL); |
2028 | if (!map_entries) | 2028 | if (!map_entries) |
2029 | return -ENOMEM; | 2029 | return -ENOMEM; |
2030 | 2030 | ||
@@ -2122,7 +2122,7 @@ out: | |||
2122 | } else | 2122 | } else |
2123 | core_alua_set_lba_map(dev, &lba_list, | 2123 | core_alua_set_lba_map(dev, &lba_list, |
2124 | segment_size, segment_mult); | 2124 | segment_size, segment_mult); |
2125 | kfree(map_entries); | 2125 | kfree(orig); |
2126 | return count; | 2126 | return count; |
2127 | } | 2127 | } |
2128 | 2128 | ||