]> git.baikalelectronics.ru Git - kernel.git/commitdiff
can: kvaser_usb: Fix use of uninitialized completion
authorAnssi Hannula <anssi.hannula@bitwise.fi>
Mon, 10 Oct 2022 15:08:27 +0000 (17:08 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:22:13 +0000 (13:22 +0200)
commit 07026682cf1ab1236bdddce8c8e4fb984d31a0d1 upstream.

flush_comp is initialized when CMD_FLUSH_QUEUE is sent to the device and
completed when the device sends CMD_FLUSH_QUEUE_RESP.

This causes completion of uninitialized completion if the device sends
CMD_FLUSH_QUEUE_RESP before CMD_FLUSH_QUEUE is ever sent (e.g. as a
response to a flush by a previously bound driver, or a misbehaving
device).

Fix that by initializing flush_comp in kvaser_usb_init_one() like the
other completions.

This issue is only triggerable after RX URBs have been set up, i.e. the
interface has been opened at least once.

Cc: stable@vger.kernel.org
Fixes: a55fe6fb9371 ("can: kvaser_usb: Add support for Kvaser USB hydra family")
Tested-by: Jimmy Assarsson <extja@kvaser.com>
Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Link: https://lore.kernel.org/all/20221010150829.199676-3-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c

index 416763fd1f11c8cd3205b20781f3e8560ec0ac0d..38fb3decb12654c9e0b5d488370f39d3ef05cc95 100644 (file)
@@ -690,6 +690,7 @@ static int kvaser_usb_init_one(struct kvaser_usb *dev, int channel)
        init_usb_anchor(&priv->tx_submitted);
        init_completion(&priv->start_comp);
        init_completion(&priv->stop_comp);
+       init_completion(&priv->flush_comp);
        priv->can.ctrlmode_supported = 0;
 
        priv->dev = dev;
index 01d4a731b579c1071b956d38a0653d8f8f299f19..5d642458bac547f1c9823b9eacda5e4dceb7d9d4 100644 (file)
@@ -1886,7 +1886,7 @@ static int kvaser_usb_hydra_flush_queue(struct kvaser_usb_net_priv *priv)
 {
        int err;
 
-       init_completion(&priv->flush_comp);
+       reinit_completion(&priv->flush_comp);
 
        err = kvaser_usb_hydra_send_simple_cmd(priv->dev, CMD_FLUSH_QUEUE,
                                               priv->channel);