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/xattr.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/xattr.c')
-rw-r--r-- | fs/ceph/xattr.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index 5a492caf34cb..5c4c9c256931 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c | |||
@@ -877,16 +877,23 @@ static int ceph_sync_setxattr(struct dentry *dentry, const char *name, | |||
877 | err = PTR_ERR(req); | 877 | err = PTR_ERR(req); |
878 | goto out; | 878 | goto out; |
879 | } | 879 | } |
880 | req->r_inode = inode; | 880 | |
881 | ihold(inode); | ||
882 | req->r_inode_drop = CEPH_CAP_XATTR_SHARED; | ||
883 | req->r_num_caps = 1; | ||
884 | req->r_args.setxattr.flags = cpu_to_le32(flags); | 881 | req->r_args.setxattr.flags = cpu_to_le32(flags); |
885 | req->r_path2 = kstrdup(name, GFP_NOFS); | 882 | req->r_path2 = kstrdup(name, GFP_NOFS); |
883 | if (!req->r_path2) { | ||
884 | ceph_mdsc_put_request(req); | ||
885 | err = -ENOMEM; | ||
886 | goto out; | ||
887 | } | ||
886 | 888 | ||
887 | req->r_pagelist = pagelist; | 889 | req->r_pagelist = pagelist; |
888 | pagelist = NULL; | 890 | pagelist = NULL; |
889 | 891 | ||
892 | req->r_inode = inode; | ||
893 | ihold(inode); | ||
894 | req->r_num_caps = 1; | ||
895 | req->r_inode_drop = CEPH_CAP_XATTR_SHARED; | ||
896 | |||
890 | dout("xattr.ver (before): %lld\n", ci->i_xattrs.version); | 897 | dout("xattr.ver (before): %lld\n", ci->i_xattrs.version); |
891 | err = ceph_mdsc_do_request(mdsc, NULL, req); | 898 | err = ceph_mdsc_do_request(mdsc, NULL, req); |
892 | ceph_mdsc_put_request(req); | 899 | ceph_mdsc_put_request(req); |
@@ -1019,12 +1026,14 @@ static int ceph_send_removexattr(struct dentry *dentry, const char *name) | |||
1019 | USE_AUTH_MDS); | 1026 | USE_AUTH_MDS); |
1020 | if (IS_ERR(req)) | 1027 | if (IS_ERR(req)) |
1021 | return PTR_ERR(req); | 1028 | return PTR_ERR(req); |
1029 | req->r_path2 = kstrdup(name, GFP_NOFS); | ||
1030 | if (!req->r_path2) | ||
1031 | return -ENOMEM; | ||
1032 | |||
1022 | req->r_inode = inode; | 1033 | req->r_inode = inode; |
1023 | ihold(inode); | 1034 | ihold(inode); |
1024 | req->r_inode_drop = CEPH_CAP_XATTR_SHARED; | ||
1025 | req->r_num_caps = 1; | 1035 | req->r_num_caps = 1; |
1026 | req->r_path2 = kstrdup(name, GFP_NOFS); | 1036 | req->r_inode_drop = CEPH_CAP_XATTR_SHARED; |
1027 | |||
1028 | err = ceph_mdsc_do_request(mdsc, NULL, req); | 1037 | err = ceph_mdsc_do_request(mdsc, NULL, req); |
1029 | ceph_mdsc_put_request(req); | 1038 | ceph_mdsc_put_request(req); |
1030 | return err; | 1039 | return err; |