linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, YueHaibing <yuehaibing@huawei.com>,
	hare@suse.de, jejb@linux.ibm.com, martin.petersen@oracle.com
Cc: lkp@intel.com, kbuild-all@lists.01.org,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	YueHaibing <yuehaibing@huawei.com>
Subject: Re: [PATCH] scsi: libfc: Fix passing zero to 'PTR_ERR' warning
Date: Fri, 21 Aug 2020 15:23:43 +0300	[thread overview]
Message-ID: <20200821122343.GS1793@kadam> (raw)
In-Reply-To: <20200818114235.51052-1-yuehaibing@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 3703 bytes --]

Hi YueHaibing,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on scsi/for-next v5.9-rc1 next-20200818]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/YueHaibing/scsi-libfc-Fix-passing-zero-to-PTR_ERR-warning/20200818-194521
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: x86_64-randconfig-m001-20200818 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/scsi/libfc/fc_disc.c:371 fc_disc_gpn_ft_req() error: uninitialized symbol 'err'.

# https://github.com/0day-ci/linux/commit/c22a185df6f9701ac244e7f2ec1ba38e27177aec
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review YueHaibing/scsi-libfc-Fix-passing-zero-to-PTR_ERR-warning/20200818-194521
git checkout c22a185df6f9701ac244e7f2ec1ba38e27177aec
vim +/err +371 drivers/scsi/libfc/fc_disc.c

42e9a92fe6a909 Robert Love     2008-12-09  342  static void fc_disc_gpn_ft_req(struct fc_disc *disc)
42e9a92fe6a909 Robert Love     2008-12-09  343  {
42e9a92fe6a909 Robert Love     2008-12-09  344  	struct fc_frame *fp;
0685230c59b548 Joe Eykholt     2010-07-20  345  	struct fc_lport *lport = fc_disc_lport(disc);
c22a185df6f970 YueHaibing      2020-08-18  346  	int err;
42e9a92fe6a909 Robert Love     2008-12-09  347  
ee35624e1e4e4e Hannes Reinecke 2018-07-04  348  	lockdep_assert_held(&disc->disc_mutex);
ee35624e1e4e4e Hannes Reinecke 2018-07-04  349  
42e9a92fe6a909 Robert Love     2008-12-09  350  	WARN_ON(!fc_lport_test_ready(lport));
42e9a92fe6a909 Robert Love     2008-12-09  351  
42e9a92fe6a909 Robert Love     2008-12-09  352  	disc->pending = 1;
42e9a92fe6a909 Robert Love     2008-12-09  353  	disc->requested = 0;
42e9a92fe6a909 Robert Love     2008-12-09  354  
42e9a92fe6a909 Robert Love     2008-12-09  355  	disc->buf_len = 0;
42e9a92fe6a909 Robert Love     2008-12-09  356  	disc->seq_count = 0;
42e9a92fe6a909 Robert Love     2008-12-09  357  	fp = fc_frame_alloc(lport,
42e9a92fe6a909 Robert Love     2008-12-09  358  			    sizeof(struct fc_ct_hdr) +
42e9a92fe6a909 Robert Love     2008-12-09  359  			    sizeof(struct fc_ns_gid_ft));
c22a185df6f970 YueHaibing      2020-08-18  360  	if (!fp) {
c22a185df6f970 YueHaibing      2020-08-18  361  		err = -ENOMEM;
42e9a92fe6a909 Robert Love     2008-12-09  362  		goto err;
c22a185df6f970 YueHaibing      2020-08-18  363  	}
42e9a92fe6a909 Robert Love     2008-12-09  364  
a46f327aa5caf2 Joe Eykholt     2009-08-25  365  	if (lport->tt.elsct_send(lport, 0, fp,
42e9a92fe6a909 Robert Love     2008-12-09  366  				 FC_NS_GPN_FT,
42e9a92fe6a909 Robert Love     2008-12-09  367  				 fc_disc_gpn_ft_resp,
b94f8951bf2566 Joe Eykholt     2009-11-03  368  				 disc, 3 * lport->r_a_tov))
42e9a92fe6a909 Robert Love     2008-12-09  369  		return;

It's Reverse the Last Condition anti-pattern.  It's a special subcase of
Success Handling anti-pattern.  Ugh...  Anyway if tt.elsct_send()
returns NULL then "err" isn't initialized.

42e9a92fe6a909 Robert Love     2008-12-09  370  err:
c22a185df6f970 YueHaibing      2020-08-18 @371  	fc_disc_error(disc, ERR_PTR(err));
42e9a92fe6a909 Robert Love     2008-12-09  372  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29592 bytes --]

  parent reply	other threads:[~2020-08-21 12:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18 11:42 [PATCH] scsi: libfc: Fix passing zero to 'PTR_ERR' warning YueHaibing
2020-08-18 16:24 ` kernel test robot
2020-08-19  2:05 ` [PATCH v2] " YueHaibing
2020-08-21  2:21   ` Martin K. Petersen
2020-08-21 11:03     ` Yuehaibing
2020-08-21 11:02 ` [PATCH v3] " YueHaibing
2020-08-21 12:23 ` Dan Carpenter [this message]
2020-09-09 13:54 ` [PATCH v4] " YueHaibing
2020-09-15 21:52   ` Martin K. Petersen
2020-09-22  3:57   ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200821122343.GS1793@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=hare@suse.de \
    --cc=jejb@linux.ibm.com \
    --cc=kbuild-all@lists.01.org \
    --cc=kbuild@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=martin.petersen@oracle.com \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).