[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <096c5828-2b86-d689-e1cb-ba7de8abbf6f@kvaser.com>
Date: Sat, 28 May 2022 09:34:53 +0200
From: Jimmy Assarsson <extja@...ser.com>
To: Anssi Hannula <anssi.hannula@...wise.fi>
Cc: linux-can@...r.kernel.org, Marc Kleine-Budde <mkl@...gutronix.de>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 02/12] can: kvaser_usb: Fix use of uninitialized
completion
On 5/16/22 15:47, Anssi Hannula wrote:
> 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.
>
> Fixes: aec5fb2268b7 ("can: kvaser_usb: Add support for Kvaser USB hydra family")
> Signed-off-by: Anssi Hannula <anssi.hannula@...wise.fi>
Looks good to me.
Tested-by: Jimmy Assarsson <extja@...ser.com>
> ---
> drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 1 +
> drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
> index e67658b53d02..47bff40c36b6 100644
> --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
> +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
> @@ -673,6 +673,7 @@ static int kvaser_usb_init_one(struct kvaser_usb *dev,
> 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;
> diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
> index a26823c5b62a..4e90a4b7f95a 100644
> --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
> +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
> @@ -1910,7 +1910,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);
Powered by blists - more mailing lists