[PATCH mtd-utils 1/2] fsck.ubifs: don't use pointers that reference out-of-scope variables
Zhihao Cheng
chengzhihao1 at huawei.com
Thu Nov 13 19:15:15 PST 2025
在 2025/11/13 16:31, Yuta Hayama 写道:
> sn is a reference to either an ino_node, dent_node, or data_node. When sn
> is actually used in calls to dbg_fsck() or insert_or_update_file(), these
> variables must not be out of scope.
>
> Signed-off-by: Yuta Hayama <hayama at lineo.co.jp>
> ---
> ubifs-utils/fsck.ubifs/check_files.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
Thanks for fixing it.
Reviewed-by: Zhihao Cheng <chengzhihao1 at huawei.com>
> diff --git a/ubifs-utils/fsck.ubifs/check_files.c b/ubifs-utils/fsck.ubifs/check_files.c
> index 1e1a77b..54300a3 100644
> --- a/ubifs-utils/fsck.ubifs/check_files.c
> +++ b/ubifs-utils/fsck.ubifs/check_files.c
> @@ -57,12 +57,13 @@ static int construct_file(struct ubifs_info *c, union ubifs_key *key,
> struct rb_root *tree = &FSCK(c)->scanned_files;
> struct scanned_node *sn = NULL;
> struct ubifs_ch *ch = (struct ubifs_ch *)node;
> + struct scanned_ino_node ino_node;
> + struct scanned_dent_node dent_node;
> + struct scanned_data_node data_node;
>
> switch (ch->node_type) {
> case UBIFS_INO_NODE:
> {
> - struct scanned_ino_node ino_node;
> -
> if (!parse_ino_node(c, lnum, offs, node, key, &ino_node)) {
> if (fix_problem(c, INVALID_INO_NODE, NULL))
> return add_invalid_node(c, key, lnum, offs, iter);
> @@ -74,8 +75,6 @@ static int construct_file(struct ubifs_info *c, union ubifs_key *key,
> case UBIFS_DENT_NODE:
> case UBIFS_XENT_NODE:
> {
> - struct scanned_dent_node dent_node;
> -
> if (!parse_dent_node(c, lnum, offs, node, key, &dent_node)) {
> if (fix_problem(c, INVALID_DENT_NODE, NULL))
> return add_invalid_node(c, key, lnum, offs, iter);
> @@ -86,8 +85,6 @@ static int construct_file(struct ubifs_info *c, union ubifs_key *key,
> }
> case UBIFS_DATA_NODE:
> {
> - struct scanned_data_node data_node;
> -
> if (!parse_data_node(c, lnum, offs, node, key, &data_node)) {
> if (fix_problem(c, INVALID_DATA_NODE, NULL))
> return add_invalid_node(c, key, lnum, offs, iter);
>
More information about the linux-mtd
mailing list