mirror of
https://github.com/sakumisu/CherryUSB.git
synced 2025-05-09 00:21:44 +08:00
fix(platform/rtthread/usbh_dfs): fix mem free
This commit is contained in:
parent
02ac1db3ff
commit
a8a5d95f8f
@ -9,7 +9,7 @@
|
|||||||
#include "rtthread.h"
|
#include "rtthread.h"
|
||||||
#include <dfs_fs.h>
|
#include <dfs_fs.h>
|
||||||
|
|
||||||
#define DEV_FORMAT "/sd%c"
|
#define DEV_FORMAT "/dev/sd%c"
|
||||||
|
|
||||||
#ifndef CONFIG_USB_DFS_MOUNT_POINT
|
#ifndef CONFIG_USB_DFS_MOUNT_POINT
|
||||||
#define CONFIG_USB_DFS_MOUNT_POINT "/"
|
#define CONFIG_USB_DFS_MOUNT_POINT "/"
|
||||||
@ -175,15 +175,17 @@ int udisk_init(struct usbh_msc *msc_class)
|
|||||||
ret = usbh_msc_scsi_read10(msc_class, 0, msc_sector, 1);
|
ret = usbh_msc_scsi_read10(msc_class, 0, msc_sector, 1);
|
||||||
if (ret != RT_EOK) {
|
if (ret != RT_EOK) {
|
||||||
rt_kprintf("usb mass_storage read failed\n");
|
rt_kprintf("usb mass_storage read failed\n");
|
||||||
|
rt_free(dev);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
/* Get the first partition */
|
/* Get the first partition */
|
||||||
ret = dfs_filesystem_get_partition(&part0, msc_sector, i);
|
ret = dfs_filesystem_get_partition(&part0, msc_sector, i);
|
||||||
if (ret == RT_EOK) {
|
if (ret == RT_EOK) {
|
||||||
rt_kprintf("Found partition %d: type = %d, offet=0x%x, size=0x%x\n",
|
rt_kprintf("Found partition %d: type = %d, offet=0x%x, size=0x%x\n",
|
||||||
i, part0.type, part0.offset, part0.size);
|
i, part0.type, part0.offset, part0.size);
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -219,6 +221,8 @@ void usbh_msc_run(struct usbh_msc *msc_class)
|
|||||||
|
|
||||||
void usbh_msc_stop(struct usbh_msc *msc_class)
|
void usbh_msc_stop(struct usbh_msc *msc_class)
|
||||||
{
|
{
|
||||||
|
struct rt_device *dev;
|
||||||
|
|
||||||
char name[CONFIG_USBHOST_DEV_NAMELEN];
|
char name[CONFIG_USBHOST_DEV_NAMELEN];
|
||||||
char mount_point[CONFIG_USBHOST_DEV_NAMELEN];
|
char mount_point[CONFIG_USBHOST_DEV_NAMELEN];
|
||||||
|
|
||||||
@ -226,5 +230,9 @@ void usbh_msc_stop(struct usbh_msc *msc_class)
|
|||||||
snprintf(mount_point, CONFIG_USBHOST_DEV_NAMELEN, CONFIG_USB_DFS_MOUNT_POINT, msc_class->sdchar);
|
snprintf(mount_point, CONFIG_USBHOST_DEV_NAMELEN, CONFIG_USB_DFS_MOUNT_POINT, msc_class->sdchar);
|
||||||
|
|
||||||
dfs_unmount(mount_point);
|
dfs_unmount(mount_point);
|
||||||
rt_device_unregister(rt_device_find(name));
|
dev = rt_device_find(name);
|
||||||
|
if (dev) {
|
||||||
|
rt_device_unregister(dev);
|
||||||
|
rt_free(dev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user