Skip to content

Commit

Permalink
Merge tag 'ubifs-for-linus-6.11-rc1-take2' of git://git.kernel.org/pu…
Browse files Browse the repository at this point in the history
…b/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
  • Loading branch information
torvalds committed Jul 28, 2024
2 parents e172f1e + 92a286e commit 7e2d0ba
Show file tree
Hide file tree
Showing 21 changed files with 135 additions and 214 deletions.
9 changes: 5 additions & 4 deletions drivers/mtd/ubi/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ int ubiblock_create(struct ubi_volume_info *vi)

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

Expand All @@ -407,8 +408,8 @@ int ubiblock_create(struct ubi_volume_info *vi)
gd->minors = 1;
gd->first_minor = idr_alloc(&ubiblock_minor_idr, dev, 0, 0, GFP_KERNEL);
if (gd->first_minor < 0) {
dev_err(disk_to_dev(gd),
"block: dynamic minor allocation failed");
pr_err("ubiblock%d_%d: block: dynamic minor allocation failed\n",
dev->ubi_num, dev->vol_id);
ret = -ENODEV;
goto out_cleanup_disk;
}
Expand Down Expand Up @@ -669,7 +670,7 @@ int __init ubiblock_init(void)
return ret;
}

void __exit ubiblock_exit(void)
void ubiblock_exit(void)
{
ubi_unregister_volume_notifier(&ubiblock_notifier);
ubiblock_remove_all();
Expand Down
7 changes: 5 additions & 2 deletions drivers/mtd/ubi/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static struct attribute *ubi_class_attrs[] = {
ATTRIBUTE_GROUPS(ubi_class);

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

/* See comment above re-ubi_is_module(). */
if (ubi_is_module())
goto out_slab;
goto out_debugfs;
}

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

out_mtd_notifier:
unregister_mtd_user(&ubi_mtd_notifier);
ubiblock_exit();
out_debugfs:
ubi_debugfs_exit();
out_slab:
kmem_cache_destroy(ubi_wl_entry_slab);
out_dev_unreg:
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/ubi/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,9 @@ int ubi_debugfs_init_dev(struct ubi_device *ubi)
if (!IS_ENABLED(CONFIG_DEBUG_FS))
return 0;

n = snprintf(d->dfs_dir_name, UBI_DFS_DIR_LEN + 1, UBI_DFS_DIR_NAME,
n = snprintf(d->dfs_dir_name, UBI_DFS_DIR_LEN, UBI_DFS_DIR_NAME,
ubi->ubi_num);
if (n > UBI_DFS_DIR_LEN) {
if (n >= UBI_DFS_DIR_LEN) {
/* The array size is too small */
return -EINVAL;
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/mtd/ubi/eba.c
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
GFP_KERNEL);
if (!fm_eba[i]) {
ret = -ENOMEM;
kfree(scan_eba[i]);
goto out_free;
}

Expand Down Expand Up @@ -1599,7 +1600,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
}

out_free:
for (i = 0; i < num_volumes; i++) {
while (--i >= 0) {
if (!ubi->volumes[i])
continue;

Expand Down
6 changes: 3 additions & 3 deletions drivers/mtd/ubi/nvmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/* UBI NVMEM provider */
#include "ubi.h"
#include <linux/nvmem-provider.h>
#include <asm/div64.h>

/* List of all NVMEM devices */
static LIST_HEAD(nvmem_devices);
Expand All @@ -27,14 +26,15 @@ static int ubi_nvmem_reg_read(void *priv, unsigned int from,
struct ubi_nvmem *unv = priv;
struct ubi_volume_desc *desc;
uint32_t offs;
uint64_t lnum = from;
uint32_t lnum;
int err = 0;

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

offs = do_div(lnum, unv->usable_leb_size);
offs = from % unv->usable_leb_size;
lnum = from / unv->usable_leb_size;
while (bytes_left) {
to_read = unv->usable_leb_size - offs;

Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/ubi/ubi.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ struct ubi_debug_info {
unsigned int power_cut_min;
unsigned int power_cut_max;
unsigned int emulate_failures;
char dfs_dir_name[UBI_DFS_DIR_LEN + 1];
char dfs_dir_name[UBI_DFS_DIR_LEN];
struct dentry *dfs_dir;
struct dentry *dfs_chk_gen;
struct dentry *dfs_chk_io;
Expand Down Expand Up @@ -814,7 +814,7 @@ extern struct kmem_cache *ubi_wl_entry_slab;
extern const struct file_operations ubi_ctrl_cdev_operations;
extern const struct file_operations ubi_cdev_operations;
extern const struct file_operations ubi_vol_cdev_operations;
extern struct class ubi_class;
extern const struct class ubi_class;
extern struct mutex ubi_devices_mutex;
extern struct blocking_notifier_head ubi_notifiers;

Expand Down
2 changes: 2 additions & 0 deletions fs/ubifs/compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];

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

/**
* ubifs_decompress - decompress data.
* @c: UBIFS file-system description object
* @in_buf: data to decompress
* @in_len: length of the data to decompress
* @out_buf: output buffer where decompressed data should
Expand Down
4 changes: 2 additions & 2 deletions fs/ubifs/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -2827,9 +2827,9 @@ void dbg_debugfs_init_fs(struct ubifs_info *c)
const char *fname;
struct ubifs_debug_info *d = c->dbg;

n = snprintf(d->dfs_dir_name, UBIFS_DFS_DIR_LEN + 1, UBIFS_DFS_DIR_NAME,
n = snprintf(d->dfs_dir_name, UBIFS_DFS_DIR_LEN, UBIFS_DFS_DIR_NAME,
c->vi.ubi_num, c->vi.vol_id);
if (n > UBIFS_DFS_DIR_LEN) {
if (n >= UBIFS_DFS_DIR_LEN) {
/* The array size is too small */
return;
}
Expand Down
7 changes: 4 additions & 3 deletions fs/ubifs/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ typedef int (*dbg_znode_callback)(struct ubifs_info *c,

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

/**
* ubifs_debug_info - per-FS debugging information.
Expand Down Expand Up @@ -103,7 +104,7 @@ struct ubifs_debug_info {
unsigned int chk_fs:1;
unsigned int tst_rcvry:1;

char dfs_dir_name[UBIFS_DFS_DIR_LEN + 1];
char dfs_dir_name[UBIFS_DFS_DIR_LEN];
struct dentry *dfs_dir;
struct dentry *dfs_dump_lprops;
struct dentry *dfs_dump_budg;
Expand Down
Loading

0 comments on commit 7e2d0ba

Please sign in to comment.