public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] cifs: fix error code in cifs_match_super()
@ 2014-06-20 19:22 Dan Carpenter
  2014-06-21 20:06 ` Shirish Pargaonkar
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2014-06-20 19:22 UTC (permalink / raw)
  To: Steve French, Pavel Shilovsky
  Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

It looks like there is a typo here where return "rc" which is "success"
instead of PTR_ERR(tlink) which is a negative error code.

I have also removed the unneeded initialization so that GCC has a chance
to warn about this sort of thing next time.

Fixes: 25c7f41e9234 ('CIFS: Migrate to shared superblock model')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is a static checker warning and I'm not certain this is the correct
fix.  Please review this one carefully.

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 20d75b8..a5704e1 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2730,14 +2730,14 @@ cifs_match_super(struct super_block *sb, void *data)
 	struct cifs_ses *ses;
 	struct cifs_tcon *tcon;
 	struct tcon_link *tlink;
-	int rc = 0;
+	int rc;
 
 	spin_lock(&cifs_tcp_ses_lock);
 	cifs_sb = CIFS_SB(sb);
 	tlink = cifs_get_tlink(cifs_sb_master_tlink(cifs_sb));
 	if (IS_ERR(tlink)) {
 		spin_unlock(&cifs_tcp_ses_lock);
-		return rc;
+		return PTR_ERR(tlink);
 	}
 	tcon = tlink_tcon(tlink);
 	ses = tcon->ses;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] cifs: fix error code in cifs_match_super()
  2014-06-20 19:22 [patch] cifs: fix error code in cifs_match_super() Dan Carpenter
@ 2014-06-21 20:06 ` Shirish Pargaonkar
  0 siblings, 0 replies; 2+ messages in thread
From: Shirish Pargaonkar @ 2014-06-21 20:06 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Steve French, Pavel Shilovsky, linux-cifs,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, samba-technical

I do not think his is correct. cifs_match_super return code is used as
a test by sb_get,
so if there is any error/mismatch within cifs_match_super, it should
return 0. 'if (test)' in sb_get() will succeed with PTR_ERR(tlink) which
would be incorrect.

On Fri, Jun 20, 2014 at 2:22 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> It looks like there is a typo here where return "rc" which is "success"
> instead of PTR_ERR(tlink) which is a negative error code.
>
> I have also removed the unneeded initialization so that GCC has a chance
> to warn about this sort of thing next time.
>
> Fixes: 25c7f41e9234 ('CIFS: Migrate to shared superblock model')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> This is a static checker warning and I'm not certain this is the correct
> fix.  Please review this one carefully.
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 20d75b8..a5704e1 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -2730,14 +2730,14 @@ cifs_match_super(struct super_block *sb, void *data)
>         struct cifs_ses *ses;
>         struct cifs_tcon *tcon;
>         struct tcon_link *tlink;
> -       int rc = 0;
> +       int rc;
>
>         spin_lock(&cifs_tcp_ses_lock);
>         cifs_sb = CIFS_SB(sb);
>         tlink = cifs_get_tlink(cifs_sb_master_tlink(cifs_sb));
>         if (IS_ERR(tlink)) {
>                 spin_unlock(&cifs_tcp_ses_lock);
> -               return rc;
> +               return PTR_ERR(tlink);
>         }
>         tcon = tlink_tcon(tlink);
>         ses = tcon->ses;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-21 20:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-20 19:22 [patch] cifs: fix error code in cifs_match_super() Dan Carpenter
2014-06-21 20:06 ` Shirish Pargaonkar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox