lkml.org 
[lkml]   [2018]   [Sep]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 14/33] vfs: Implement a filesystem superblock creation/configuration context [ver #11]
    On (09/18/18 17:39), David Howells wrote:
    [..]
    > -static int legacy_init_fs_context(struct fs_context *fc, struct dentry *dentry)
    > +int legacy_init_fs_context(struct fs_context *fc, struct dentry *dentry)
    > {
    > + switch (fc->purpose) {
    > + default:
    > + fc->fs_private = kzalloc(sizeof(struct legacy_fs_context),
    > + GFP_KERNEL);
    > + if (!fc->fs_private)
    > + return -ENOMEM;

    ops->reconfigure() invoked for FS_CONTEXT_FOR_UMOUNT or
    FS_CONTEXT_FOR_EMERGENCY_RO will never access fc->fs_private?

    > + break;
    >
    > - fc->fs_private = kzalloc(sizeof(struct legacy_fs_context), GFP_KERNEL);
    > - if (!fc->fs_private)
    > - return -ENOMEM;
    > + case FS_CONTEXT_FOR_UMOUNT:
    > + case FS_CONTEXT_FOR_EMERGENCY_RO:
    > + break;
    > + }

    So `fc' can either be zeroed-out, when it comes from fc = kzalloc(),
    or contain some garbage otherwise. Would it make sense to zero-out `fc'
    regardless of its origin?

    > down_write(&sb->s_umount);
    > - if (!sb_rdonly(sb))
    > - /* Might want to call ->init_fs_context(). */
    > - ret = reconfigure_super(&fc);
    > + if (!sb_rdonly(sb)) {
    > + int ret;
    > +
    > + if (fc.fs_type->init_fs_context)
    > + ret = fc.fs_type->init_fs_context(&fc, NULL);
    > + else
    > + ret = legacy_init_fs_context(&fc, NULL);
    > +
    > + if (ret == 0) {
    > + ret = reconfigure_super(&fc);
    > + fc.ops->free(&fc);
    ^^^^^^^
    Is ops->free() always !NULL?

    -ss

    \
     
     \ /
      Last update: 2018-09-19 03:16    [W:5.251 / U:0.136 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site