From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@01.org, Douglas Gilbert <dgilbert@interlog.com>
Cc: jejb@linux.vnet.ibm.com, martin.petersen@oracle.com,
linux-scsi@vger.kernel.org, hare@suse.de, bart.vanassche@wdc.com,
kbuild-all@01.org
Subject: Re: [PATCH 13/19] sg: sgat_elem_sz and sum_fd_dlens
Date: Mon, 27 May 2019 11:28:52 +0300 [thread overview]
Message-ID: <20190527082852.GF24680@kadam> (raw)
In-Reply-To: <20190524184809.25121-14-dgilbert@interlog.com>
Hi Douglas,
Thank you for the patch! Perhaps something to improve:
url: https://github.com/0day-ci/linux/commits/Douglas-Gilbert/sg-v4-interface-rq-sharing-multiple-rqs/20190525-161346
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
drivers/scsi/sg.c:3374 sg_remove_sgat() error: we previously assumed 'sfp' could be null (see line 3367)
Old smatch warnings:
drivers/scsi/sg.c:4383 sg_proc_seq_show_dbg() warn: returning -1 instead of -ENOMEM is sloppy
# https://github.com/0day-ci/linux/commit/ecbddf3329c05a33a780f39084acb2f104067d6a
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout ecbddf3329c05a33a780f39084acb2f104067d6a
vim +/sfp +3374 drivers/scsi/sg.c
c5ad643d Douglas Gilbert 2019-05-24 3358
c5ad643d Douglas Gilbert 2019-05-24 3359 /* Remove the data (possibly a sgat list) held by srp, not srp itself */
c5ad643d Douglas Gilbert 2019-05-24 3360 static void
c5ad643d Douglas Gilbert 2019-05-24 3361 sg_remove_sgat(struct sg_request *srp)
c5ad643d Douglas Gilbert 2019-05-24 3362 {
c5ad643d Douglas Gilbert 2019-05-24 3363 struct sg_scatter_hold *schp = &srp->sgat_h; /* care: remove own data */
c5ad643d Douglas Gilbert 2019-05-24 3364 struct sg_fd *sfp = srp->parentfp;
c5ad643d Douglas Gilbert 2019-05-24 3365 struct sg_device *sdp;
c5ad643d Douglas Gilbert 2019-05-24 3366
c5ad643d Douglas Gilbert 2019-05-24 @3367 sdp = (sfp ? sfp->parentdp : NULL);
^^^
Null heck
c5ad643d Douglas Gilbert 2019-05-24 3368 SG_LOG(4, sdp, "%s: num_sgat=%d%s\n", __func__, schp->num_sgat,
c5ad643d Douglas Gilbert 2019-05-24 3369 ((srp->parentfp ? (sfp->rsv_srp == srp) : false) ?
c5ad643d Douglas Gilbert 2019-05-24 3370 " [rsv]" : ""));
c5ad643d Douglas Gilbert 2019-05-24 3371 if (!test_bit(SG_FRQ_DIO_IN_USE, srp->frq_bm))
c5ad643d Douglas Gilbert 2019-05-24 3372 sg_remove_sgat_helper(sdp, schp);
c5ad643d Douglas Gilbert 2019-05-24 3373
ecbddf33 Douglas Gilbert 2019-05-24 @3374 if (sfp->tot_fd_thresh > 0) {
^^^^^^^^^^^^^^^^^^
Unchecked dereference.
ecbddf33 Douglas Gilbert 2019-05-24 3375 /* this is a subtraction, error if it goes negative */
ecbddf33 Douglas Gilbert 2019-05-24 3376 if (atomic_add_negative(-schp->buflen, &sfp->sum_fd_dlens)) {
ecbddf33 Douglas Gilbert 2019-05-24 3377 SG_LOG(2, sfp->parentdp,
ecbddf33 Douglas Gilbert 2019-05-24 3378 "%s: logic error: this dlen > %s\n",
ecbddf33 Douglas Gilbert 2019-05-24 3379 __func__, "sum_fd_dlens");
ecbddf33 Douglas Gilbert 2019-05-24 3380 atomic_set(&sfp->sum_fd_dlens, 0);
ecbddf33 Douglas Gilbert 2019-05-24 3381 }
ecbddf33 Douglas Gilbert 2019-05-24 3382 }
c5ad643d Douglas Gilbert 2019-05-24 3383 memset(schp, 0, sizeof(*schp)); /* zeros buflen and dlen */
^1da177e Linus Torvalds 2005-04-16 3384 }
^1da177e Linus Torvalds 2005-04-16 3385
parent reply other threads:[~2019-05-27 8:28 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20190524184809.25121-14-dgilbert@interlog.com>]
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=20190527082852.GF24680@kadam \
--to=dan.carpenter@oracle.com \
--cc=bart.vanassche@wdc.com \
--cc=dgilbert@interlog.com \
--cc=hare@suse.de \
--cc=jejb@linux.vnet.ibm.com \
--cc=kbuild-all@01.org \
--cc=kbuild@01.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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