From: Suwan Kim <suwan.kim027@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: kbuild@lists.01.org, kbuild-all@lists.01.org,
linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, shuah@kernel.org
Subject: Re: drivers/usb/usbip/stub_rx.c:505 stub_recv_cmd_submit() error: uninitialized symbol 'nents'.
Date: Wed, 23 Oct 2019 16:11:20 +0900 [thread overview]
Message-ID: <20191023071120.GA3061@localhost.localdomain> (raw)
In-Reply-To: <20191022092839.GD10833@kadam>
On Tue, Oct 22, 2019 at 12:28:39PM +0300, Dan Carpenter wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 7d194c2100ad2a6dded545887d02754948ca5241
> commit: ea44d190764b4422af4d1c29eaeb9e69e353b406 usbip: Implement SG support to vhci-hcd and stub driver
> date: 7 weeks ago
>
> 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/usb/usbip/stub_rx.c:505 stub_recv_cmd_submit() error: uninitialized symbol 'nents'.
>
> Old smatch warnings:
> drivers/usb/usbip/stub_rx.c:450 stub_recv_xbuff() error: uninitialized symbol 'ret'.
>
> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ea44d190764b4422af4d1c29eaeb9e69e353b406
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git remote update linus
> git checkout ea44d190764b4422af4d1c29eaeb9e69e353b406
> vim +/nents +505 drivers/usb/usbip/stub_rx.c
>
> 4d7b5c7f8ad49b drivers/staging/usbip/stub_rx.c Takahiro Hirofuchi 2008-07-09 453 static void stub_recv_cmd_submit(struct stub_device *sdev,
> 4d7b5c7f8ad49b drivers/staging/usbip/stub_rx.c Takahiro Hirofuchi 2008-07-09 454 struct usbip_header *pdu)
> 4d7b5c7f8ad49b drivers/staging/usbip/stub_rx.c Takahiro Hirofuchi 2008-07-09 455 {
> 4d7b5c7f8ad49b drivers/staging/usbip/stub_rx.c Takahiro Hirofuchi 2008-07-09 456 struct stub_priv *priv;
> 4d7b5c7f8ad49b drivers/staging/usbip/stub_rx.c Takahiro Hirofuchi 2008-07-09 457 struct usbip_device *ud = &sdev->ud;
> 2d8f4595d1f275 drivers/staging/usbip/stub_rx.c Max Vozeler 2011-01-12 458 struct usb_device *udev = sdev->udev;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 459 struct scatterlist *sgl = NULL, *sg;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 460 void *buffer = NULL;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 461 unsigned long long buf_len;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 462 int nents;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 463 int num_urbs = 1;
> c6688ef9f29762 drivers/usb/usbip/stub_rx.c Shuah Khan 2017-12-07 464 int pipe = get_pipe(sdev, pdu);
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 465 int use_sg = pdu->u.cmd_submit.transfer_flags & URB_DMA_MAP_SG;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 466 int support_sg = 1;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 467 int np = 0;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 468 int ret, i;
> 4d7b5c7f8ad49b drivers/staging/usbip/stub_rx.c Takahiro Hirofuchi 2008-07-09 469
> 635f545a7e8be7 drivers/usb/usbip/stub_rx.c Shuah Khan 2017-12-07 470 if (pipe == -1)
> 635f545a7e8be7 drivers/usb/usbip/stub_rx.c Shuah Khan 2017-12-07 471 return;
> 4d7b5c7f8ad49b drivers/staging/usbip/stub_rx.c Takahiro Hirofuchi 2008-07-09 472
> 4d7b5c7f8ad49b drivers/staging/usbip/stub_rx.c Takahiro Hirofuchi 2008-07-09 473 priv = stub_priv_alloc(sdev, pdu);
> 4d7b5c7f8ad49b drivers/staging/usbip/stub_rx.c Takahiro Hirofuchi 2008-07-09 474 if (!priv)
> 4d7b5c7f8ad49b drivers/staging/usbip/stub_rx.c Takahiro Hirofuchi 2008-07-09 475 return;
> 4d7b5c7f8ad49b drivers/staging/usbip/stub_rx.c Takahiro Hirofuchi 2008-07-09 476
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 477 buf_len = (unsigned long long)pdu->u.cmd_submit.transfer_buffer_length;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 478
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 479 /* allocate urb transfer buffer, if needed */
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 480 if (buf_len) {
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 481 if (use_sg) {
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 482 sgl = sgl_alloc(buf_len, GFP_KERNEL, &nents);
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 483 if (!sgl)
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 484 goto err_malloc;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 485 } else {
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 486 buffer = kzalloc(buf_len, GFP_KERNEL);
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 487 if (!buffer)
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 488 goto err_malloc;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 489 }
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 490 }
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 491
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 492 /* Check if the server's HCD supports SG */
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 493 if (use_sg && !udev->bus->sg_tablesize) {
>
> Smatch thinks "use_sg" can be true when "buf_len" is zero. It's hard
> to tell if Smatch is right or wrong without more context...
This is a bit strange. The meaning of "use_sg" is that client will
use scatter-gather and client's urb->num_sgs is not zero. And buffer
length should not be zero.
usb_sg and buf_len are both client-dependent variables, so I think
if they have wrong value in the server side, the client must have
sent use_sg and buf_len with incorrect values.
Did this error occur when compiling? If then, Did Smatch also
consider vhci tx side?
Regards
Suwan Kim
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 494 /*
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 495 * If the server's HCD doesn't support SG, break a single SG
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 496 * request into several URBs and map each SG list entry to
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 497 * corresponding URB buffer. The previously allocated SG
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 498 * list is stored in priv->sgl (If the server's HCD support SG,
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 499 * SG list is stored only in urb->sg) and it is used as an
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 500 * indicator that the server split single SG request into
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 501 * several URBs. Later, priv->sgl is used by stub_complete() and
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 502 * stub_send_ret_submit() to reassemble the divied URBs.
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 503 */
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 504 support_sg = 0;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 @505 num_urbs = nents;
> ^^^^^^^^^^^^^^^^
>
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 506 priv->completed_urbs = 0;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 507 pdu->u.cmd_submit.transfer_flags &= ~URB_DMA_MAP_SG;
> ea44d190764b44 drivers/usb/usbip/stub_rx.c Suwan Kim 2019-08-28 508 }
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
next prev parent reply other threads:[~2019-10-23 7:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 9:28 drivers/usb/usbip/stub_rx.c:505 stub_recv_cmd_submit() error: uninitialized symbol 'nents' Dan Carpenter
2019-10-23 7:11 ` Suwan Kim [this message]
2019-10-24 19:45 ` Dan Carpenter
2019-10-24 22:52 ` shuah
2019-10-26 2:41 ` Suwan Kim
2019-10-30 8:19 ` Dan Carpenter
2019-10-26 3:40 ` Suwan Kim
2019-10-29 11:07 ` shuah
2019-11-01 14:34 ` Suwan Kim
2019-11-04 17:07 ` shuah
2019-11-11 2:45 ` Suwan Kim
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=20191023071120.GA3061@localhost.localdomain \
--to=suwan.kim027@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=kbuild-all@lists.01.org \
--cc=kbuild@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=shuah@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;
as well as URLs for NNTP newsgroup(s).