gfapi: fix crash of using uninitialized fs->ctx

0  0x00007fb3db3a2ee4 in pub_glfs_fini (fs=0x7f8977d63f00) at glfs.c:1236
1  0x00007fb3db3a2065 in pub_glfs_new (volname=0x7f80de4d4d40 "openfs1")
    at glfs.c:784
2  0x00007fb3db5cf089 in glusterfs_get_fs (params=...,
    up_ops=up_ops@entry=0x7fb3ca643130)
    at /usr/src/debug/nfs-ganesha/src/FSAL/FSAL_GLUSTER/export.c:889
3  0x00007fb3db5cf99a in glusterfs_create_export (
    fsal_hdl=0x7fb3db7e2490 <GlusterFS+112>, parse_node=0x7fb3ca6387d0,
    err_type=<optimized out>, up_ops=0x7fb3ca643130)
    at /usr/src/debug/nfs-ganesha/src/FSAL/FSAL_GLUSTER/export.c:1011
4  0x00007fb3e11c485f in mdcache_fsal_create_export (
    sub_fsal=0x7fb3db7e2490 <GlusterFS+112>,
    parse_node=parse_node@entry=0x7fb3ca6387d0,
    err_type=err_type@entry=0x7fb3c0bef140, super_up_ops=<optimized out>)
    at /usr/src/debug/nfs-ganesha/src/FSAL/Stackable_FSALs/FSAL_MDCACHE/mdcache_main.c:281

(gdb) p errno
$1 = 12

Change-Id: I3dd5b84b52962ceb0b5d4f9b4f475bf4aa724292
updates: bz#1626313
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
This commit is contained in:
Kinglong Mee 2018-09-19 03:35:38 -04:00 committed by Poornima G
parent 196b32423a
commit 27d3d481bd

View File

@ -1221,13 +1221,18 @@ pub_glfs_fini(struct glfs *fs)
DECLARE_OLD_THIS;
__GLFS_ENTRY_VALIDATE_FS(fs, invalid_fs);
if (!fs) {
errno = EINVAL;
goto invalid_fs;
}
ctx = fs->ctx;
if (!ctx) {
goto free_fs;
}
THIS = fs->ctx->master;
if (ctx->mgmt) {
rpc_clnt_disable(ctx->mgmt);
}