summaryrefslogtreecommitdiff
path: root/fs/ceph/super.c
diff options
context:
space:
mode:
authorSanidhya Kashyap <sanidhya.gatech@gmail.com>2015-03-21 19:54:58 +0300
committerIlya Dryomov <idryomov@gmail.com>2015-04-20 18:55:34 +0300
commita149bb9a281c5c2904cf6fcdf9ed386340032ce3 (patch)
tree644078c1ab0c063382210f3d0b43a239070b1364 /fs/ceph/super.c
parentc1d00b2d9c4fc821e33c5cdfbdbc32677cb0e2e0 (diff)
downloadlinux-a149bb9a281c5c2904cf6fcdf9ed386340032ce3.tar.xz
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.c10
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;