mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 06:43:53 -06:00

ASAN spotted a leak of the memory used to hold the tmp_path: Direct leak of 35 byte(s) in 1 object(s) allocated from: #0 0x55e29aa96da9 in malloc ../projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3 #1 0x7fe0cfb26518 in g_malloc ../glib/gmem.c:106 #2 0x7fe0cfb4146e in g_strconcat ../glib/gstrfuncs.c:629 #3 0x7fe0cfb0a78f in g_get_tmp_name ../glib/gfileutils.c:1742 #4 0x7fe0cfb0b00b in g_file_open_tmp ../glib/gfileutils.c:1802 #5 0x55e29ab53961 in test_ast2700_evb ../tests/qtest/ast2700-smc-test.c:20:10 #6 0x55e29ab53803 in main ../tests/qtest/ast2700-smc-test.c:65:5 #7 0x7fe0cf7bd24c in __libc_start_main ../csu/libc-start.c:308 #8 0x55e29a9f7759 in _start ../sysdeps/x86_64/start.S:120 Signed-off-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Jamin Lin <jamin_lin@aspeedtech.com> Message-ID: <20250509175047.26066-1-farosas@suse.de> Signed-off-by: Cédric Le Goater <clg@redhat.com>
72 lines
2.2 KiB
C
72 lines
2.2 KiB
C
/*
|
|
* QTest testcase for the M25P80 Flash using the ASPEED SPI Controller since
|
|
* AST2700.
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright (C) 2024 ASPEED Technology Inc.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qemu/bswap.h"
|
|
#include "libqtest-single.h"
|
|
#include "qemu/bitops.h"
|
|
#include "aspeed-smc-utils.h"
|
|
|
|
static void test_ast2700_evb(AspeedSMCTestData *data)
|
|
{
|
|
int ret;
|
|
int fd;
|
|
|
|
fd = g_file_open_tmp("qtest.m25p80.w25q01jvq.XXXXXX",
|
|
&data->tmp_path, NULL);
|
|
g_assert(fd >= 0);
|
|
ret = ftruncate(fd, 128 * 1024 * 1024);
|
|
g_assert(ret == 0);
|
|
close(fd);
|
|
|
|
data->s = qtest_initf("-machine ast2700-evb "
|
|
"-drive file=%s,format=raw,if=mtd",
|
|
data->tmp_path);
|
|
|
|
/* fmc cs0 with w25q01jvq flash */
|
|
data->flash_base = 0x100000000;
|
|
data->spi_base = 0x14000000;
|
|
data->jedec_id = 0xef4021;
|
|
data->cs = 0;
|
|
data->node = "/machine/soc/fmc/ssi.0/child[0]";
|
|
/* beyond 64MB */
|
|
data->page_addr = 0x40000 * FLASH_PAGE_SIZE;
|
|
|
|
qtest_add_data_func("/ast2700/smc/read_jedec",
|
|
data, aspeed_smc_test_read_jedec);
|
|
qtest_add_data_func("/ast2700/smc/erase_sector",
|
|
data, aspeed_smc_test_erase_sector);
|
|
qtest_add_data_func("/ast2700/smc/erase_all",
|
|
data, aspeed_smc_test_erase_all);
|
|
qtest_add_data_func("/ast2700/smc/write_page",
|
|
data, aspeed_smc_test_write_page);
|
|
qtest_add_data_func("/ast2700/smc/read_page_mem",
|
|
data, aspeed_smc_test_read_page_mem);
|
|
qtest_add_data_func("/ast2700/smc/write_page_mem",
|
|
data, aspeed_smc_test_write_page_mem);
|
|
qtest_add_data_func("/ast2700/smc/read_status_reg",
|
|
data, aspeed_smc_test_read_status_reg);
|
|
qtest_add_data_func("/ast2700/smc/write_page_qpi",
|
|
data, aspeed_smc_test_write_page_qpi);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
AspeedSMCTestData ast2700_evb_data;
|
|
int ret;
|
|
|
|
g_test_init(&argc, &argv, NULL);
|
|
|
|
test_ast2700_evb(&ast2700_evb_data);
|
|
ret = g_test_run();
|
|
|
|
qtest_quit(ast2700_evb_data.s);
|
|
unlink(ast2700_evb_data.tmp_path);
|
|
g_free(ast2700_evb_data.tmp_path);
|
|
return ret;
|
|
}
|