From: Dan Carpenter <dan.carpenter@oracle.com>
To: jthumshirn@suse.de
Cc: linux-scsi@vger.kernel.org
Subject: [bug report] scsi: sg: fix SG_DXFER_FROM_DEV transfers
Date: Fri, 14 Jul 2017 10:46:03 +0300 [thread overview]
Message-ID: <20170714074603.7mi6jshrz6zfru4b@mwanda> (raw)
Hello Johannes Thumshirn,
The patch 68c59fcea1f2: "scsi: sg: fix SG_DXFER_FROM_DEV transfers"
from Jul 7, 2017, leads to the following static checker warning:
drivers/scsi/sg.c:762 sg_is_valid_dxfer()
warn: unsigned 'hp->dxfer_len' is never less than zero.
drivers/scsi/sg.c
754 static bool sg_is_valid_dxfer(sg_io_hdr_t *hp)
755 {
756 switch (hp->dxfer_direction) {
757 case SG_DXFER_NONE:
758 if (hp->dxferp || hp->dxfer_len > 0)
759 return false;
760 return true;
761 case SG_DXFER_FROM_DEV:
762 if (hp->dxfer_len < 0)
^^^^^^^^^^^^^^^^^
Not possible.
763 return false;
764 return true;
765 case SG_DXFER_TO_DEV:
766 case SG_DXFER_TO_FROM_DEV:
767 if (!hp->dxferp || hp->dxfer_len == 0)
768 return false;
769 return true;
770 case SG_DXFER_UNKNOWN:
771 if ((!hp->dxferp && hp->dxfer_len) ||
772 (hp->dxferp && hp->dxfer_len == 0))
773 return false;
774 return true;
775 default:
776 return false;
777 }
778 }
Btw, I was looking up the type of hp->dxfer_len and I noticed that the
documentation for hp->resid is wrong. It says:
int resid; /* [o] dxfer_len - actual_transferred */
My guess is that resid stands for Response ID but I'm not positive.
regards,
dan carpenter
next reply other threads:[~2017-07-14 7:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-14 7:46 Dan Carpenter [this message]
2017-07-14 9:01 ` [bug report] scsi: sg: fix SG_DXFER_FROM_DEV transfers Johannes Thumshirn
2017-07-14 9:16 ` Dan Carpenter
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=20170714074603.7mi6jshrz6zfru4b@mwanda \
--to=dan.carpenter@oracle.com \
--cc=jthumshirn@suse.de \
--cc=linux-scsi@vger.kernel.org \
/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