Skip to content

Commit 7e2d0ba

Browse files
committed
Merge tag 'ubifs-for-linus-6.11-rc1-take2' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs
Pull UBI and UBIFS updates from Richard Weinberger: - Many fixes for power-cut issues by Zhihao Cheng - Another ubiblock error path fix - ubiblock section mismatch fix - Misc fixes all over the place * tag 'ubifs-for-linus-6.11-rc1-take2' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs: ubi: Fix ubi_init() ubiblock_exit() section mismatch ubifs: add check for crypto_shash_tfm_digest ubifs: Fix inconsistent inode size when powercut happens during appendant writing ubi: block: fix null-pointer-dereference in ubiblock_create() ubifs: fix kernel-doc warnings ubifs: correct UBIFS_DFS_DIR_LEN macro definition and improve code clarity mtd: ubi: Restore missing cleanup on ubi_init() failure path ubifs: dbg_orphan_check: Fix missed key type checking ubifs: Fix unattached inode when powercut happens in creating ubifs: Fix space leak when powercut happens in linking tmpfile ubifs: Move ui->data initialization after initializing security ubifs: Fix adding orphan entry twice for the same inode ubifs: Remove insert_dead_orphan from replaying orphan process Revert "ubifs: ubifs_symlink: Fix memleak of inode->i_link in error path" ubifs: Don't add xattr inode into orphan area ubifs: Fix unattached xattr inode if powercut happens after deleting mtd: ubi: avoid expensive do_div() on 32-bit machines mtd: ubi: make ubi_class constant ubi: eba: properly rollback inside self_check_eba
2 parents e172f1e + 92a286e commit 7e2d0ba

File tree

21 files changed

+135
-214
lines changed

21 files changed

+135
-214
lines changed

drivers/mtd/ubi/block.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ int ubiblock_create(struct ubi_volume_info *vi)
390390

391391
ret = blk_mq_alloc_tag_set(&dev->tag_set);
392392
if (ret) {
393-
dev_err(disk_to_dev(dev->gd), "blk_mq_alloc_tag_set failed");
393+
pr_err("ubiblock%d_%d: blk_mq_alloc_tag_set failed\n",
394+
dev->ubi_num, dev->vol_id);
394395
goto out_free_dev;
395396
}
396397

@@ -407,8 +408,8 @@ int ubiblock_create(struct ubi_volume_info *vi)
407408
gd->minors = 1;
408409
gd->first_minor = idr_alloc(&ubiblock_minor_idr, dev, 0, 0, GFP_KERNEL);
409410
if (gd->first_minor < 0) {
410-
dev_err(disk_to_dev(gd),
411-
"block: dynamic minor allocation failed");
411+
pr_err("ubiblock%d_%d: block: dynamic minor allocation failed\n",
412+
dev->ubi_num, dev->vol_id);
412413
ret = -ENODEV;
413414
goto out_cleanup_disk;
414415
}
@@ -669,7 +670,7 @@ int __init ubiblock_init(void)
669670
return ret;
670671
}
671672

672-
void __exit ubiblock_exit(void)
673+
void ubiblock_exit(void)
673674
{
674675
ubi_unregister_volume_notifier(&ubiblock_notifier);
675676
ubiblock_remove_all();

drivers/mtd/ubi/build.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static struct attribute *ubi_class_attrs[] = {
112112
ATTRIBUTE_GROUPS(ubi_class);
113113

114114
/* Root UBI "class" object (corresponds to '/<sysfs>/class/ubi/') */
115-
struct class ubi_class = {
115+
const struct class ubi_class = {
116116
.name = UBI_NAME_STR,
117117
.class_groups = ubi_class_groups,
118118
};
@@ -1372,7 +1372,7 @@ static int __init ubi_init(void)
13721372

13731373
/* See comment above re-ubi_is_module(). */
13741374
if (ubi_is_module())
1375-
goto out_slab;
1375+
goto out_debugfs;
13761376
}
13771377

13781378
register_mtd_user(&ubi_mtd_notifier);
@@ -1387,6 +1387,9 @@ static int __init ubi_init(void)
13871387

13881388
out_mtd_notifier:
13891389
unregister_mtd_user(&ubi_mtd_notifier);
1390+
ubiblock_exit();
1391+
out_debugfs:
1392+
ubi_debugfs_exit();
13901393
out_slab:
13911394
kmem_cache_destroy(ubi_wl_entry_slab);
13921395
out_dev_unreg:

drivers/mtd/ubi/debug.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,9 @@ int ubi_debugfs_init_dev(struct ubi_device *ubi)
598598
if (!IS_ENABLED(CONFIG_DEBUG_FS))
599599
return 0;
600600

601-
n = snprintf(d->dfs_dir_name, UBI_DFS_DIR_LEN + 1, UBI_DFS_DIR_NAME,
601+
n = snprintf(d->dfs_dir_name, UBI_DFS_DIR_LEN, UBI_DFS_DIR_NAME,
602602
ubi->ubi_num);
603-
if (n > UBI_DFS_DIR_LEN) {
603+
if (n >= UBI_DFS_DIR_LEN) {
604604
/* The array size is too small */
605605
return -EINVAL;
606606
}

drivers/mtd/ubi/eba.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
15641564
GFP_KERNEL);
15651565
if (!fm_eba[i]) {
15661566
ret = -ENOMEM;
1567+
kfree(scan_eba[i]);
15671568
goto out_free;
15681569
}
15691570

@@ -1599,7 +1600,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
15991600
}
16001601

16011602
out_free:
1602-
for (i = 0; i < num_volumes; i++) {
1603+
while (--i >= 0) {
16031604
if (!ubi->volumes[i])
16041605
continue;
16051606

drivers/mtd/ubi/nvmem.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
/* UBI NVMEM provider */
77
#include "ubi.h"
88
#include <linux/nvmem-provider.h>
9-
#include <asm/div64.h>
109

1110
/* List of all NVMEM devices */
1211
static LIST_HEAD(nvmem_devices);
@@ -27,14 +26,15 @@ static int ubi_nvmem_reg_read(void *priv, unsigned int from,
2726
struct ubi_nvmem *unv = priv;
2827
struct ubi_volume_desc *desc;
2928
uint32_t offs;
30-
uint64_t lnum = from;
29+
uint32_t lnum;
3130
int err = 0;
3231

3332
desc = ubi_open_volume(unv->ubi_num, unv->vol_id, UBI_READONLY);
3433
if (IS_ERR(desc))
3534
return PTR_ERR(desc);
3635

37-
offs = do_div(lnum, unv->usable_leb_size);
36+
offs = from % unv->usable_leb_size;
37+
lnum = from / unv->usable_leb_size;
3838
while (bytes_left) {
3939
to_read = unv->usable_leb_size - offs;
4040

drivers/mtd/ubi/ubi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ struct ubi_debug_info {
420420
unsigned int power_cut_min;
421421
unsigned int power_cut_max;
422422
unsigned int emulate_failures;
423-
char dfs_dir_name[UBI_DFS_DIR_LEN + 1];
423+
char dfs_dir_name[UBI_DFS_DIR_LEN];
424424
struct dentry *dfs_dir;
425425
struct dentry *dfs_chk_gen;
426426
struct dentry *dfs_chk_io;
@@ -814,7 +814,7 @@ extern struct kmem_cache *ubi_wl_entry_slab;
814814
extern const struct file_operations ubi_ctrl_cdev_operations;
815815
extern const struct file_operations ubi_cdev_operations;
816816
extern const struct file_operations ubi_vol_cdev_operations;
817-
extern struct class ubi_class;
817+
extern const struct class ubi_class;
818818
extern struct mutex ubi_devices_mutex;
819819
extern struct blocking_notifier_head ubi_notifiers;
820820

fs/ubifs/compress.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
8282

8383
/**
8484
* ubifs_compress - compress data.
85+
* @c: UBIFS file-system description object
8586
* @in_buf: data to compress
8687
* @in_len: length of the data to compress
8788
* @out_buf: output buffer where compressed data should be stored
@@ -140,6 +141,7 @@ void ubifs_compress(const struct ubifs_info *c, const void *in_buf,
140141

141142
/**
142143
* ubifs_decompress - decompress data.
144+
* @c: UBIFS file-system description object
143145
* @in_buf: data to decompress
144146
* @in_len: length of the data to decompress
145147
* @out_buf: output buffer where decompressed data should

fs/ubifs/debug.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,9 +2827,9 @@ void dbg_debugfs_init_fs(struct ubifs_info *c)
28272827
const char *fname;
28282828
struct ubifs_debug_info *d = c->dbg;
28292829

2830-
n = snprintf(d->dfs_dir_name, UBIFS_DFS_DIR_LEN + 1, UBIFS_DFS_DIR_NAME,
2830+
n = snprintf(d->dfs_dir_name, UBIFS_DFS_DIR_LEN, UBIFS_DFS_DIR_NAME,
28312831
c->vi.ubi_num, c->vi.vol_id);
2832-
if (n > UBIFS_DFS_DIR_LEN) {
2832+
if (n >= UBIFS_DFS_DIR_LEN) {
28332833
/* The array size is too small */
28342834
return;
28352835
}

fs/ubifs/debug.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ typedef int (*dbg_znode_callback)(struct ubifs_info *c,
1919

2020
/*
2121
* The UBIFS debugfs directory name pattern and maximum name length (3 for "ubi"
22-
* + 1 for "_" and plus 2x2 for 2 UBI numbers and 1 for the trailing zero byte.
22+
* + 1 for "_" and 2 for UBI device numbers and 3 for volume number and 1 for
23+
* the trailing zero byte.
2324
*/
2425
#define UBIFS_DFS_DIR_NAME "ubi%d_%d"
25-
#define UBIFS_DFS_DIR_LEN (3 + 1 + 2*2 + 1)
26+
#define UBIFS_DFS_DIR_LEN (3 + 1 + 2 + 3 + 1)
2627

2728
/**
2829
* ubifs_debug_info - per-FS debugging information.
@@ -103,7 +104,7 @@ struct ubifs_debug_info {
103104
unsigned int chk_fs:1;
104105
unsigned int tst_rcvry:1;
105106

106-
char dfs_dir_name[UBIFS_DFS_DIR_LEN + 1];
107+
char dfs_dir_name[UBIFS_DFS_DIR_LEN];
107108
struct dentry *dfs_dir;
108109
struct dentry *dfs_dump_lprops;
109110
struct dentry *dfs_dump_budg;

0 commit comments

Comments
 (0)