All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [bug report] usb: hso: obey DMA rules in tiocmget
Date: Sat, 19 Oct 2019 08:54:51 +0000	[thread overview]
Message-ID: <20191019085451.GA13915@mwanda> (raw)

Hello Oliver Neukum,

The patch af0de1303c4e: "usb: hso: obey DMA rules in tiocmget" from
Oct 17, 2019, leads to the following static checker warning:

	drivers/net/usb/hso.c:2626 hso_create_bulk_serial_device()
	warn: variable dereferenced before check 'serial->tiocmget' (see line 2620)

drivers/net/usb/hso.c
  2615  
  2616          if ((port & HSO_PORT_MASK) = HSO_PORT_MODEM) {
  2617                  num_urbs = 2;
  2618                  serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget),
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
Allocation

  2619                                             GFP_KERNEL);
  2620                  serial->tiocmget->serial_state_notification
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dereference

  2621                          = kzalloc(sizeof(struct hso_serial_state_notification),
  2622                                             GFP_KERNEL);
  2623                  /* it isn't going to break our heart if serial->tiocmget
  2624                   *  allocation fails don't bother checking this.
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Comment says not to check for failure.

  2625                   */
  2626                  if (serial->tiocmget && serial->tiocmget->serial_state_notification) {
                            ^^^^^^^^^^^^^^^^
Check too late.

  2627                          tiocmget = serial->tiocmget;
  2628                          tiocmget->endp = hso_get_ep(interface,
  2629                                                      USB_ENDPOINT_XFER_INT,
  2630                                                      USB_DIR_IN);
  2631                          if (!tiocmget->endp) {
  2632                                  dev_err(&interface->dev, "Failed to find INT IN ep\n");
  2633                                  goto exit;
  2634                          }
  2635  
  2636                          tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL);
  2637                          if (tiocmget->urb) {
  2638                                  mutex_init(&tiocmget->mutex);
  2639                                  init_waitqueue_head(&tiocmget->waitq);
  2640                          } else
  2641                                  hso_free_tiomget(serial);
  2642                  }
  2643          }
  2644          else
  2645                  num_urbs = 1;


regards,
dan carpenter

                 reply	other threads:[~2019-10-19  8:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20191019085451.GA13915@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.