Merge tag 'for-linus-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 18 Oct 2020 16:51:10 +0000 (09:51 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 18 Oct 2020 16:51:10 +0000 (09:51 -0700)
Pull ubifs updates from Richard Weinberger:

 - Kernel-doc fixes

 - Fixes for memory leaks in authentication option parsing

* tag 'for-linus-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs:
  ubifs: mount_ubifs: Release authentication resource in error handling path
  ubifs: Don't parse authentication mount options in remount process
  ubifs: Fix a memleak after dumping authentication mount options
  ubifs: Fix some kernel-doc warnings in tnc.c
  ubifs: Fix some kernel-doc warnings in replay.c
  ubifs: Fix some kernel-doc warnings in gc.c
  ubifs: Fix 'hash' kernel-doc warning in auth.c

1  2 
fs/ubifs/super.c

diff --combined fs/ubifs/super.c
@@@ -1110,14 -1110,20 +1110,20 @@@ static int ubifs_parse_options(struct u
                        break;
                }
                case Opt_auth_key:
-                       c->auth_key_name = kstrdup(args[0].from, GFP_KERNEL);
-                       if (!c->auth_key_name)
-                               return -ENOMEM;
+                       if (!is_remount) {
+                               c->auth_key_name = kstrdup(args[0].from,
+                                                               GFP_KERNEL);
+                               if (!c->auth_key_name)
+                                       return -ENOMEM;
+                       }
                        break;
                case Opt_auth_hash_name:
-                       c->auth_hash_name = kstrdup(args[0].from, GFP_KERNEL);
-                       if (!c->auth_hash_name)
-                               return -ENOMEM;
+                       if (!is_remount) {
+                               c->auth_hash_name = kstrdup(args[0].from,
+                                                               GFP_KERNEL);
+                               if (!c->auth_hash_name)
+                                       return -ENOMEM;
+                       }
                        break;
                case Opt_ignore:
                        break;
        return 0;
  }
  
+ /*
+  * ubifs_release_options - release mount parameters which have been dumped.
+  * @c: UBIFS file-system description object
+  */
+ static void ubifs_release_options(struct ubifs_info *c)
+ {
+       kfree(c->auth_key_name);
+       c->auth_key_name = NULL;
+       kfree(c->auth_hash_name);
+       c->auth_hash_name = NULL;
+ }
  /**
   * destroy_journal - destroy journal data structures.
   * @c: UBIFS file-system description object
@@@ -1313,7 -1331,7 +1331,7 @@@ static int mount_ubifs(struct ubifs_inf
  
        err = ubifs_read_superblock(c);
        if (err)
-               goto out_free;
+               goto out_auth;
  
        c->probing = 0;
  
                ubifs_err(c, "'compressor \"%s\" is not compiled in",
                          ubifs_compr_name(c, c->default_compr));
                err = -ENOTSUPP;
-               goto out_free;
+               goto out_auth;
        }
  
        err = init_constants_sb(c);
        if (err)
-               goto out_free;
+               goto out_auth;
  
        sz = ALIGN(c->max_idx_node_sz, c->min_io_size) * 2;
        c->cbuf = kmalloc(sz, GFP_NOFS);
        if (!c->cbuf) {
                err = -ENOMEM;
-               goto out_free;
+               goto out_auth;
        }
  
        err = alloc_wbufs(c);
@@@ -1611,6 -1629,8 +1629,8 @@@ out_wbufs
        free_wbufs(c);
  out_cbuf:
        kfree(c->cbuf);
+ out_auth:
+       ubifs_exit_authentication(c);
  out_free:
        kfree(c->write_reserve_buf);
        kfree(c->bu.buf);
@@@ -1650,8 -1670,7 +1670,7 @@@ static void ubifs_umount(struct ubifs_i
        ubifs_lpt_free(c, 0);
        ubifs_exit_authentication(c);
  
-       kfree(c->auth_key_name);
-       kfree(c->auth_hash_name);
+       ubifs_release_options(c);
        kfree(c->cbuf);
        kfree(c->rcvrd_mst_node);
        kfree(c->mst_node);
@@@ -2177,8 -2196,6 +2196,8 @@@ static int ubifs_fill_super(struct supe
                                   c->vi.vol_id);
        if (err)
                goto out_close;
 +      sb->s_bdi->ra_pages = 0;
 +      sb->s_bdi->io_pages = 0;
  
        sb->s_fs_info = c;
        sb->s_magic = UBIFS_SUPER_MAGIC;
@@@ -2221,6 -2238,7 +2240,7 @@@ out_umount
  out_unlock:
        mutex_unlock(&c->umount_mutex);
  out_close:
+       ubifs_release_options(c);
        ubi_close_volume(c->ubi);
  out:
        return err;