rptun: fix memleak on failure

Leak backtrace:
    1 14 2096 9886 0x4318d768 [0x040320744] <romfs_fileconfigure+184> romfs/fs_romfsutil.c:1039
                                                 [0x04031fd3e] <romfs_open+378> romfs/fs_romfs.c:281
                                                 [0x04027fa9e] <file_open+446> vfs/fs_open.c:244
                                                 [0x0402ab986] <rptun_store_open+26> rptun/rptun.c:955
                                                 [0x04034cc88] <remoteproc_load+120> open-amp/lib/remoteproc/remoteproc.c:452
                                                 [0x0402ac8ac] <rptun_dev_start+176> rptun/rptun.c:748
                                                 [0x0402ad038] <rptun_ioctl+416> rptun/rptun.c:618

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
xuxingliang
2024-08-23 19:44:11 +08:00
committed by Xiang Xiao
parent dbe43b0ae9
commit 75b87a85dd
+7 -1
View File
@@ -1022,7 +1022,13 @@ static int rptun_store_open(FAR void *store_,
*img_data = store->buf;
return file_read(&store->file, store->buf, len);
ret = file_read(&store->file, store->buf, len);
if (ret < 0)
{
file_close(&store->file);
}
return ret;
}
static void rptun_store_close(FAR void *store_)