From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9701AC6FA91 for ; Wed, 21 Sep 2022 07:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230360AbiIUHkK (ORCPT ); Wed, 21 Sep 2022 03:40:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230351AbiIUHkI (ORCPT ); Wed, 21 Sep 2022 03:40:08 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 611B8303C3 for ; Wed, 21 Sep 2022 00:40:07 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oauKx-0007oR-V9; Wed, 21 Sep 2022 09:40:04 +0200 Received: from pengutronix.de (hardanger-2.fritz.box [IPv6:2a03:f580:87bc:d400:f566:9915:77e6:ceb3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id 24B10E84B0; Wed, 21 Sep 2022 07:40:03 +0000 (UTC) Date: Wed, 21 Sep 2022 09:40:02 +0200 From: Marc Kleine-Budde To: john@jbrengineering.co.uk Cc: linux-can@vger.kernel.org, John Whittington Subject: Re: [PATCH 3/3] can: gs_usb: gs_can_open(): initialize time counter before starting device Message-ID: <20220921074002.6pjrqzh6hk5v5iqm@pengutronix.de> References: <20220920100416.959226-1-mkl@pengutronix.de> <20220920100416.959226-4-mkl@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="zgs4epnjpb5t2qim" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-can@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-can@vger.kernel.org --zgs4epnjpb5t2qim Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. > >=20 > > Close the race window by setting up the timecounter before starting > > the CAN controller. >=20 > 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. >=20 > 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. >=20 > if (rc < 0) { > netdev_err(netdev, "Couldn't start device (err=3D%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 --=20 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 | --zgs4epnjpb5t2qim Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEBsvAIBsPu6mG7thcrX5LkNig010FAmMqv9AACgkQrX5LkNig 013FtQf/ZnDIN8rfScheRxfuVjzctqRQKkKW0eIMGLe7ARtG95rMqf0Ldr+8J6Ok 8kZk8Moy8RuA6+R+CJnlvifudYNQaN5GhGHR0Kxd4jFSuBH74lAihtyh2khs8TK1 XwetHqiCy2fHnv4RyQG0Z+skQHA85ChOwHsOo9mDLp7Td2fpycZUwRfge2AGt/K1 j0b7ZDqZp0Q+LbGb09KdsVfLzk1Ci+gfhEq++ihpem2lT0MS66ehTHlRkydRemmr DjRCkQC5Z4ymK1taDQSBpA9ZXVgOMpKgJ1ZWQ1S5gqofcM+AkAd3gJr6hRnWujfL O7P3O3FZKpheqHjswgJyjVueIO/XMA== =8Zw5 -----END PGP SIGNATURE----- --zgs4epnjpb5t2qim--