mirror of
https://github.com/linux-msm/openocd.git
synced 2026-02-25 13:15:07 -08:00
flash/nor/mdr: add docs, remove memory leak on probe()
This adds the mandatory Info documentation for the driver as well as the usage field. As a clean up, this also includes freeing of the allocated memory which results in a memory leak if probe is invoked multiple times. Valgrind-tested. Reported by Dmitry Shpak. Change-Id: I2b1d9b9e8b069c6665b11d880b40ce19a1b26ce6 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/2694 Tested-by: jenkins Reviewed-by: Дмитрий Шпак <disona@yandex.ru> Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
This commit is contained in:
@@ -482,6 +482,11 @@ static int mdr_probe(struct flash_bank *bank)
|
||||
page_count = mdr_info->page_count;
|
||||
page_size = bank->size / page_count;
|
||||
|
||||
if (bank->sectors) {
|
||||
free(bank->sectors);
|
||||
bank->sectors = NULL;
|
||||
}
|
||||
|
||||
bank->num_sectors = page_count;
|
||||
bank->sectors = malloc(sizeof(struct flash_sector) * page_count);
|
||||
|
||||
@@ -516,6 +521,8 @@ static int get_mdr_info(struct flash_bank *bank, char *buf, int buf_size)
|
||||
|
||||
struct flash_driver mdr_flash = {
|
||||
.name = "mdr",
|
||||
.usage = "flash bank <name> mdr <base> <size> 0 0 <target#> <type> <page_count> <sec_count>\n"
|
||||
"<type>: 0 for main memory, 1 for info memory",
|
||||
.flash_bank_command = mdr_flash_bank_command,
|
||||
.erase = mdr_erase,
|
||||
.protect = mdr_protect,
|
||||
|
||||
Reference in New Issue
Block a user