You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.3 KiB

  1. ===
  2. SMB1/SMB2 don't know exactly how vfs layer allocates xattr list,
  3. via kmalloc() or vmalloc(). Introduce cifsd_vfs_xattr_free() and
  4. keep both xattr allocation and de-allocation in one place.
  5. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
  6. ---
  7. smb1pdu.c | 4 ++--
  8. smb2pdu.c | 6 ++----
  9. vfs.c | 6 ++++++
  10. vfs.h | 1 +
  11. 4 files changed, 11 insertions(+), 6 deletions(-)
  12. diff --git a/smb1pdu.c b/smb1pdu.c
  13. index 35599ef..8cb92cf 100644
  14. --- a/smb1pdu.c
  15. +++ b/smb1pdu.c
  16. @@ -8,6 +8,7 @@
  17. #include <linux/posix_acl_xattr.h>
  18. #include <linux/namei.h>
  19. #include <linux/statfs.h>
  20. +#include <linux/vmalloc.h>
  21. #include "glob.h"
  22. #include "smb1pdu.h"
  23. @@ -3844,8 +3845,7 @@ done:
  24. rsp->ByteCount = cpu_to_le16(rsp_data_cnt + 5);
  25. inc_rfc1001_len(&rsp->hdr, (10 * 2 + rsp->ByteCount));
  26. out:
  27. - if (xattr_list)
  28. - vfree(xattr_list);
  29. + cifsd_vfs_xattr_free(xattr_list);
  30. return rc;
  31. }
  32. diff --git a/smb2pdu.c b/smb2pdu.c
  33. index 754258f..2727622 100644
  34. --- a/smb2pdu.c
  35. +++ b/smb2pdu.c
  36. @@ -3867,8 +3867,7 @@ done:
  37. rsp->OutputBufferLength = cpu_to_le32(rsp_data_cnt);
  38. inc_rfc1001_len(rsp_org, rsp_data_cnt);
  39. out:
  40. - if (xattr_list)
  41. - vfree(xattr_list);
  42. + cifsd_vfs_xattr_free(xattr_list);
  43. return rc;
  44. }
  45. @@ -4151,8 +4150,7 @@ static void get_file_stream_info(struct cifsd_work *work,
  46. /* last entry offset should be 0 */
  47. file_info->NextEntryOffset = 0;
  48. out:
  49. - if (xattr_list)
  50. - vfree(xattr_list);
  51. + cifsd_vfs_xattr_free(xattr_list);
  52. rsp->OutputBufferLength = cpu_to_le32(nbytes);
  53. inc_rfc1001_len(rsp_org, nbytes);
  54. diff --git a/vfs.c b/vfs.c
  55. index 556b1a5..6da6f8e 100644
  56. --- a/vfs.c
  57. +++ b/vfs.c
  58. @@ -1550,6 +1550,12 @@ int cifsd_vfs_remove_xattr(struct dentry *dentry, char *attr_name)
  59. return vfs_removexattr(dentry, attr_name);
  60. }
  61. +void cifsd_vfs_xattr_free(char *xattr)
  62. +{
  63. + if (xattr)
  64. + vfree(xattr);
  65. +}
  66. +
  67. int cifsd_vfs_unlink(struct dentry *dir, struct dentry *dentry)
  68. {
  69. int err = 0;
  70. diff --git a/vfs.h b/vfs.h
  71. index ee54daf..16b4f9e 100644
  72. --- a/vfs.h
  73. +++ b/vfs.h
  74. @@ -186,6 +186,7 @@ int cifsd_vfs_xattr_stream_name(char *stream_name,
  75. int cifsd_vfs_truncate_xattr(struct dentry *dentry, int wo_streams);
  76. int cifsd_vfs_remove_xattr(struct dentry *dentry, char *attr_name);
  77. +void cifsd_vfs_xattr_free(char *xattr);
  78. int cifsd_vfs_kern_path(char *name, unsigned int flags, struct path *path,
  79. bool caseless);