Message ID | 1583250197-10786-1-git-send-email-hqjagain@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fs/cifs/cifsacl: fix sid_to_id | expand |
Doesn't rc = 0 have to be set earlier (preferably in the declaration on line 345)? since line 392 does goto got_valid_id; which appears to leave rc unitialized with your change On Tue, Mar 3, 2020 at 9:56 AM Qiujun Huang <hqjagain@gmail.com> wrote: > > fix it to return the errcode. > > Signed-off-by: Qiujun Huang <hqjagain@gmail.com> > --- > fs/cifs/cifsacl.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c > index 716574a..a8d2aa8 100644 > --- a/fs/cifs/cifsacl.c > +++ b/fs/cifs/cifsacl.c > @@ -400,6 +400,7 @@ > if (!sidstr) > return -ENOMEM; > > + rc = 0; > saved_cred = override_creds(root_cred); > sidkey = request_key(&cifs_idmap_key_type, sidstr, ""); > if (IS_ERR(sidkey)) { > @@ -454,7 +455,7 @@ > fattr->cf_uid = fuid; > else > fattr->cf_gid = fgid; > - return 0; > + return rc; > } > > int > -- > 1.8.3.1 >
On Wed, Mar 4, 2020 at 4:13 AM Steve French <smfrench@gmail.com> wrote: > > Doesn't rc = 0 have to be set earlier (preferably in the declaration > on line 345)? > > since line 392 does > goto got_valid_id; > which appears to leave rc unitialized with your change > ok, I noticed that fall back to using the mnt_uid/mnt_gid. Should we remove the variable 'rc'. It is set but not used. And I was confused last time. (: diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 716574a..1cf3916 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -342,7 +342,6 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid, struct cifs_fattr *fattr, uint sidtype) { - int rc; struct key *sidkey; char *sidstr; const struct cred *saved_cred; @@ -403,7 +402,6 @@ saved_cred = override_creds(root_cred); sidkey = request_key(&cifs_idmap_key_type, sidstr, ""); if (IS_ERR(sidkey)) { - rc = -EINVAL; cifs_dbg(FYI, "%s: Can't map SID %s to a %cid\n", __func__, sidstr, sidtype == SIDOWNER ? 'u' : 'g'); goto out_revert_creds; @@ -416,7 +414,6 @@ */ BUILD_BUG_ON(sizeof(uid_t) != sizeof(gid_t)); if (sidkey->datalen != sizeof(uid_t)) { - rc = -EIO; cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu)\n", __func__, sidkey->datalen); key_invalidate(sidkey);
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 716574a..a8d2aa8 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -400,6 +400,7 @@ if (!sidstr) return -ENOMEM; + rc = 0; saved_cred = override_creds(root_cred); sidkey = request_key(&cifs_idmap_key_type, sidstr, ""); if (IS_ERR(sidkey)) { @@ -454,7 +455,7 @@ fattr->cf_uid = fuid; else fattr->cf_gid = fgid; - return 0; + return rc; } int
fix it to return the errcode. Signed-off-by: Qiujun Huang <hqjagain@gmail.com> --- fs/cifs/cifsacl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)