From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E3E62192FA for ; Mon, 23 Mar 2026 10:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774262186; cv=none; b=NKD3/8eSQoLpKpzkdBwn9DsLarlmek8FfQEzQ7BGIA72gjW2wbf7m3TeKZyAedG5LiLnsJ21yj180PfYOu4wsI5cBZ9eBtB4cAElICI/zfX2IEXwrfuGd8UACNRilm2rlEEhjYnqfv57rk6ng8O5OGaZoRjouacfuV6UGNNDwoE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774262186; c=relaxed/simple; bh=84cWpFOEfJUrl7OHPV0gcP7TAT6ro+QeEH6UHJ61bvI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bHqdosjwwMRwNUrMfvEwKK3su4vbMYuJDYsb00gsRkaCroQ8m6uW7kohVYs5sADo1bbVGhcV2Znxb8wOZuW/bXmHaT3O1Ur0yAoK5o4dsRuSBQHn5+S8m5vpCjo+QmXQmykm9SWtqRR6BYftxB+AauBMpfXsJc+Q6XNAmhaqHK4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1w4cdw-0000dP-Ab; Mon, 23 Mar 2026 11:36:20 +0100 Received: from moin.white.stw.pengutronix.de ([2a0a:edc0:0:b01:1d::7b] helo=bjornoya.blackshift.org) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w4cdv-001iAm-1I; Mon, 23 Mar 2026 11:36:19 +0100 Received: from pengutronix.de (p4ffb2dc6.dip0.t-ipconnect.de [79.251.45.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 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 114E250A7F9; Mon, 23 Mar 2026 10:36:19 +0000 (UTC) Date: Mon, 23 Mar 2026 11:36:18 +0100 From: Marc Kleine-Budde To: Matias Ezequiel Vara Larsen Cc: Harald Mommer , Vincent Mailhol , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Eugenio =?utf-8?B?UMOpcmV6?= , linux-can@vger.kernel.org, virtualization@lists.linux.dev, Mikhail Golubev-Ciuchea , Stefano Garzarella , francesco@valla.it Subject: Re: [PATCH v13] can: virtio: Add virtio CAN driver Message-ID: <20260323-hilarious-active-eagle-a0ee74-mkl@pengutronix.de> X-AI: stop_reason: "refusal" References: Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="zsnxvdx43cvgpphl" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: virtualization@lists.linux.dev --zsnxvdx43cvgpphl Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH v13] can: virtio: Add virtio CAN driver MIME-Version: 1.0 Hello, The nipa/ai-review bot found these problems: | https://netdev-ai.bots.linux.dev/ai-review.html?id=3Db046d75a-2de1-4063-b= b96-8f64abc65e7d commit 0f3cb3b3bc94eaff9b9709b528e498fe6150f9c1 Author: Matias Ezequiel Vara Larsen can: virtio: Add virtio CAN driver This commit adds a virtio CAN driver implementing a complete CAN bus interface over Virtio transport, supporting both CAN Classic and CAN-FD frames. > diff --git a/drivers/net/can/virtio_can.c b/drivers/net/can/virtio_can.c > new file mode 100644 > index 000000000000..57641c3ed6d0 > --- /dev/null > +++ b/drivers/net/can/virtio_can.c [ ... ] > +static int __maybe_unused virtio_can_restore(struct virtio_device *vdev) > +{ > + struct virtio_can_priv *priv =3D vdev->priv; > + struct net_device *ndev =3D priv->dev; > + size_t size; > + int err; > + > + napi_enable(&priv->napi); > + napi_enable(&priv->napi_tx); > + > + err =3D virtio_can_find_vqs(priv); > + if (err !=3D 0) > + return err; What happens to the enabled NAPI instances when this error path is taken? virtio_can_restore() enables both NAPI instances at the start, but if virtio_can_find_vqs() fails here, the function returns without calling napi_disable(). The corresponding virtio_can_freeze() function disables both NAPIs before returning, so the restore function leaves the NAPI subsystem in an inconsistent state on failure. If the PM framework retries restore after this failure, the second napi_enable() call on an already-enabled NAPI will hit the BUG_ON in napi_enable_locked(): net/core/dev.c:napi_enable_locked() { BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state)); ... } In contrast, virtio_can_probe() enables NAPI only after all setup succeeds, avoiding this issue. > + > + size =3D priv->rpkt_len * priv->vqs[VIRTIO_CAN_QUEUE_RX]->num_free; > + priv->rpkt =3D devm_krealloc(&vdev->dev, priv->rpkt, size, GFP_KERNEL |= __GFP_ZERO); > + if (!priv->rpkt) { > + virtio_can_del_vq(vdev); > + return -ENOMEM; > + } The same NAPI state issue occurs on this error path. > + virtio_can_populate_rx_vq(vdev); > + > + if (netif_running(ndev)) { > + err =3D virtio_can_start(ndev); > + if (err) { > + virtio_can_del_vq(vdev); > + return err; > + } And again on this error path. Should all three error paths call napi_disable(&priv->napi_tx) and napi_disable(&priv->napi) before returning the error code? --=20 Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung N=C3=BCrnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 | --zsnxvdx43cvgpphl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSl+MghEFFAdY3pYJLMOmT6rpmt0gUCacEXoAAKCRDMOmT6rpmt 0oc0AP4r/E0p8/W4XH5xFsFvHnvCil/2ybFe0uqsmduXn4Gw4QD6A2wQTTGMyyJp k6X5ros7i59H9faw/8/FWIR1ffBnmQY= =E13T -----END PGP SIGNATURE----- --zsnxvdx43cvgpphl--