diff options
Diffstat (limited to 'drivers/mtd/ubi/build.c')
| -rw-r--r-- | drivers/mtd/ubi/build.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 09a326ecd05b..4048db83aef6 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
| @@ -263,8 +263,12 @@ static ssize_t dev_attribute_show(struct device *dev, | |||
| 263 | return ret; | 263 | return ret; |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | /* Fake "release" method for UBI devices */ | 266 | static void dev_release(struct device *dev) |
| 267 | static void dev_release(struct device *dev) { } | 267 | { |
| 268 | struct ubi_device *ubi = container_of(dev, struct ubi_device, dev); | ||
| 269 | |||
| 270 | kfree(ubi); | ||
| 271 | } | ||
| 268 | 272 | ||
| 269 | /** | 273 | /** |
| 270 | * ubi_sysfs_init - initialize sysfs for an UBI device. | 274 | * ubi_sysfs_init - initialize sysfs for an UBI device. |
| @@ -944,6 +948,12 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) | |||
| 944 | if (ubi->bgt_thread) | 948 | if (ubi->bgt_thread) |
| 945 | kthread_stop(ubi->bgt_thread); | 949 | kthread_stop(ubi->bgt_thread); |
| 946 | 950 | ||
| 951 | /* | ||
| 952 | * Get a reference to the device in order to prevent 'dev_release()' | ||
| 953 | * from freeing @ubi object. | ||
| 954 | */ | ||
| 955 | get_device(&ubi->dev); | ||
| 956 | |||
| 947 | uif_close(ubi); | 957 | uif_close(ubi); |
| 948 | ubi_wl_close(ubi); | 958 | ubi_wl_close(ubi); |
| 949 | free_internal_volumes(ubi); | 959 | free_internal_volumes(ubi); |
| @@ -955,7 +965,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) | |||
| 955 | vfree(ubi->dbg_peb_buf); | 965 | vfree(ubi->dbg_peb_buf); |
| 956 | #endif | 966 | #endif |
| 957 | ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num); | 967 | ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num); |
| 958 | kfree(ubi); | 968 | put_device(&ubi->dev); |
| 959 | return 0; | 969 | return 0; |
| 960 | } | 970 | } |
| 961 | 971 | ||
