Mbed-os: lfs_emubd.c can be leaking resources

Created on 7 Mar 2019  路  6Comments  路  Source: ARMmbed/mbed-os

Description

In a number of functions in lfs_emubd.c the functions are returning when f.e. fread fails. But this is not closing the file, thus leaking the resource.

Here are all of them (from cppcheck):

[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:57]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:99]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:104]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:140]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:145]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:150]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:156]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:217]: (error) Resource leak: f
[features/storage/filesystem/littlefs/littlefs/emubd/lfs_emubd.c:233]: (error) Resource leak: f

@geky

Issue request type


[ ] Question
[ ] Enhancement
[X] Bug

CLOSED mirrored bug

All 6 comments

cc @ARMmbed/mbed-os-storage

Shouldn't this issue be placed on that repository?
ARMmbed/littlefs

@geky

I'm going to be honest, this low priority right now. emubd is used primarily for testing, and when it errors, it errors.

If you're using emubd for real applications, it would likely be a better idea to map littlefs to a real disk/file. For example: https://github.com/ARMmbed/littlefs-fuse/blob/master/lfs_fuse_bd.c

I've moved this over here https://github.com/ARMmbed/littlefs/issues/260 so it's still tracked and can be taken off your guys's backlog.

Closed as being tracked in the upstream repository where it should be fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drahnr picture drahnr  路  4Comments

bcostm picture bcostm  路  4Comments

neilt6 picture neilt6  路  4Comments

0xc0170 picture 0xc0170  路  3Comments

hasnainvirk picture hasnainvirk  路  3Comments