diff options
author | Sanidhya Kashyap <sanidhya.gatech@gmail.com> | 2015-03-21 12:54:58 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2015-04-20 11:55:34 -0400 |
commit | a149bb9a281c5c2904cf6fcdf9ed386340032ce3 (patch) | |
tree | 644078c1ab0c063382210f3d0b43a239070b1364 /fs/ceph/super.c | |
parent | c1d00b2d9c4fc821e33c5cdfbdbc32677cb0e2e0 (diff) |
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, | |||
345 | fsopt->rsize = CEPH_RSIZE_DEFAULT; | 345 | fsopt->rsize = CEPH_RSIZE_DEFAULT; |
346 | fsopt->rasize = CEPH_RASIZE_DEFAULT; | 346 | fsopt->rasize = CEPH_RASIZE_DEFAULT; |
347 | fsopt->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL); | 347 | fsopt->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL); |
348 | if (!fsopt->snapdir_name) { | ||
349 | err = -ENOMEM; | ||
350 | goto out; | ||
351 | } | ||
352 | |||
348 | fsopt->caps_wanted_delay_min = CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT; | 353 | fsopt->caps_wanted_delay_min = CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT; |
349 | fsopt->caps_wanted_delay_max = CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT; | 354 | fsopt->caps_wanted_delay_max = CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT; |
350 | fsopt->cap_release_safety = CEPH_CAP_RELEASE_SAFETY_DEFAULT; | 355 | fsopt->cap_release_safety = CEPH_CAP_RELEASE_SAFETY_DEFAULT; |
@@ -730,6 +735,11 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc, | |||
730 | if (IS_ERR(req)) | 735 | if (IS_ERR(req)) |
731 | return ERR_CAST(req); | 736 | return ERR_CAST(req); |
732 | req->r_path1 = kstrdup(path, GFP_NOFS); | 737 | req->r_path1 = kstrdup(path, GFP_NOFS); |
738 | if (!req->r_path1) { | ||
739 | root = ERR_PTR(-ENOMEM); | ||
740 | goto out; | ||
741 | } | ||
742 | |||
733 | req->r_ino1.ino = CEPH_INO_ROOT; | 743 | req->r_ino1.ino = CEPH_INO_ROOT; |
734 | req->r_ino1.snap = CEPH_NOSNAP; | 744 | req->r_ino1.snap = CEPH_NOSNAP; |
735 | req->r_started = started; | 745 | req->r_started = started; |