diff options
author | Sanidhya Kashyap <sanidhya.gatech@gmail.com> | 2015-03-21 17:54:58 +0100 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2015-04-20 17:55:34 +0200 |
commit | a149bb9a281c5c2904cf6fcdf9ed386340032ce3 (patch) | |
tree | 644078c1ab0c063382210f3d0b43a239070b1364 /fs/ceph/super.c | |
parent | ceph: properly release page upon error (diff) | |
download | linux-a149bb9a281c5c2904cf6fcdf9ed386340032ce3.tar.xz linux-a149bb9a281c5c2904cf6fcdf9ed386340032ce3.zip |
ceph: kstrdup() memory handling
Currently, there is no check for the kstrdup() for r_path2,
r_path1 and snapdir_name as various locations as there is a
possibility of failure during memory pressure. Therefore,
returning ENOMEM where the checks have been missed.
Signed-off-by: Sanidhya Kashyap <sanidhya.gatech@gmail.com>
Signed-off-by: Yan, Zheng <zyan@redhat.com>
Diffstat (limited to 'fs/ceph/super.c')
-rw-r--r-- | fs/ceph/super.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/ceph/super.c b/fs/ceph/super.c index a63997b8bcff..9f035ccb6191 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -345,6 +345,11 @@ static int parse_mount_options(struct ceph_mount_options **pfsopt, fsopt->rsize = CEPH_RSIZE_DEFAULT; fsopt->rasize = CEPH_RASIZE_DEFAULT; fsopt->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL); + if (!fsopt->snapdir_name) { + err = -ENOMEM; + goto out; + } + fsopt->caps_wanted_delay_min = CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT; fsopt->caps_wanted_delay_max = CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT; fsopt->cap_release_safety = CEPH_CAP_RELEASE_SAFETY_DEFAULT; @@ -730,6 +735,11 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc, if (IS_ERR(req)) return ERR_CAST(req); req->r_path1 = kstrdup(path, GFP_NOFS); + if (!req->r_path1) { + root = ERR_PTR(-ENOMEM); + goto out; + } + req->r_ino1.ino = CEPH_INO_ROOT; req->r_ino1.snap = CEPH_NOSNAP; req->r_started = started; |