All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: john@jbrengineering.co.uk
Cc: linux-can@vger.kernel.org, John Whittington <git@jbrengineering.co.uk>
Subject: Re: [PATCH 3/3] can: gs_usb: gs_can_open(): initialize time counter before starting device
Date: Wed, 21 Sep 2022 09:40:02 +0200	[thread overview]
Message-ID: <20220921074002.6pjrqzh6hk5v5iqm@pengutronix.de> (raw)
In-Reply-To: <WruyTFnj_BnMkA_prvKr9MgOHemFhgSpOaxf1OSJDWJQuGqc1-h6qSOctxPTwOqkzRudA-JKYxpLy_FfCR0vVaQepGCE5AC5VhcDKBzXJ0w=@jbrengineering.co.uk>

[-- Attachment #1: Type: text/plain, Size: 1496 bytes --]

On 21.09.2022 07:07:42, john@jbrengineering.co.uk wrote:
> > On busy networks the CAN controller might receive CAN frames directly
> > after starting it but before the timecounter is setup. This will lead
> > to NULL pointer deref while converting the converting the CAN frame's
> > timestamp with the timecounter.
> > 
> > Close the race window by setting up the timecounter before starting
> > the CAN controller.
> 
> My logic of starting the timer after the USB request to start was due
> to the function returning before if the USB start request returns an
> error. With this change, the timer will be started and poll the USB
> timestamp request even if the device is not started - I tested and
> confirmed this is the case.
> 
> I agree with the issue this patch solves and flaw previously but
> believe it requires a check of the GS_CAN_FEATURE_HW_TIMESTAMP and
> gs_usb_timestamp_stop(dev) in the rc < 0 check.
> 
> if (rc < 0) {
>   netdev_err(netdev, "Couldn't start device (err=%d)\n", rc);
>   kfree(dm);
>   /* stop polling timestamp */
>   if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP)
>     gs_usb_timestamp_stop(dev);
>   return rc;
> }

Right! Will fix that.

Thanks,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-09-21  7:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20 10:04 Marc Kleine-Budde
2022-09-20 10:04 ` [PATCH 1/3] can: gs_usb: gs_usb_get_timestamp(): fix endpoint parameter for usb_control_msg_recv() Marc Kleine-Budde
2022-09-20 10:04 ` [PATCH 2/3] can: gs_usb: add missing lock to protect struct timecounter::cycle_last Marc Kleine-Budde
2022-09-20 10:04 ` [PATCH 3/3] can: gs_usb: gs_can_open(): initialize time counter before starting device Marc Kleine-Budde
2022-09-21  7:07   ` john
2022-09-21  7:40     ` Marc Kleine-Budde [this message]
2022-09-21  7:07 ` (No Subject) john
2022-09-21 19:58   ` Marc Kleine-Budde
2022-09-23  7:37     ` john

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=20220921074002.6pjrqzh6hk5v5iqm@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=git@jbrengineering.co.uk \
    --cc=john@jbrengineering.co.uk \
    --cc=linux-can@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.