[PATCH] cpukit/jffs2: Avoid possible null deref

Gedare Bloom gedare at rtems.org
Thu Mar 23 01:10:35 UTC 2023


LGTM

On Wed, Mar 22, 2023 at 3:26 PM Kinsey Moore <kinsey.moore at oarcorp.com> wrote:
>
> This was added with the writebuffer work and should have been protected
> by the error check.
> ---
>  cpukit/libfs/src/jffs2/src/fs-rtems.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/cpukit/libfs/src/jffs2/src/fs-rtems.c b/cpukit/libfs/src/jffs2/src/fs-rtems.c
> index bff7d59ba1..9a0f4cb6f8 100644
> --- a/cpukit/libfs/src/jffs2/src/fs-rtems.c
> +++ b/cpukit/libfs/src/jffs2/src/fs-rtems.c
> @@ -1365,11 +1365,11 @@ int rtems_jffs2_initialize(
>                 err = -ENOMEM;
>         }
>
> -       sb = &fs_info->sb;
> -       c = JFFS2_SB_INFO(sb);
> -       c->mtd = NULL;
>
>         if (err == 0) {
> +               sb = &fs_info->sb;
> +               c = JFFS2_SB_INFO(sb);
> +               c->mtd = NULL;
>                 rtems_recursive_mutex_init(&sb->s_mutex, RTEMS_FILESYSTEM_TYPE_JFFS2);
>         }
>
> --
> 2.30.2
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list