Skip to content

Commit 16d9355

Browse files
committed
Merge tag 'linux-can-fixes-for-6.17-20250923' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can
Marc Kleine-Budde says: ==================== pull-request: can 2025-09-23 The 1st patch is by Chen Yufeng and fixes a potential NULL pointer deref in the hi311x driver. Duy Nguyen contributes a patch for the rcar_canfd driver to fix the controller mode setting. The next 4 patches are by Vincent Mailhol and populate the ndo_change_mtu(( callback in the etas_es58x, hi311x, sun4i_can and mcba_usb driver to prevent buffer overflows. Stéphane Grosjean's patch for the peak_usb driver fixes a shift-out-of-bounds issue. * tag 'linux-can-fixes-for-6.17-20250923' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can: can: peak_usb: fix shift-out-of-bounds issue can: mcba_usb: populate ndo_change_mtu() to prevent buffer overflow can: sun4i_can: populate ndo_change_mtu() to prevent buffer overflow can: hi311x: populate ndo_change_mtu() to prevent buffer overflow can: etas_es58x: populate ndo_change_mtu() to prevent buffer overflow can: rcar_canfd: Fix controller mode setting can: hi311x: fix null pointer dereference when resuming from sleep before interface was enabled ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 3d3aa94 + c443be7 commit 16d9355

File tree

6 files changed

+27
-21
lines changed

6 files changed

+27
-21
lines changed

drivers/net/can/rcar/rcar_canfd.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -823,9 +823,6 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)
823823
/* Reset Global error flags */
824824
rcar_canfd_write(gpriv->base, RCANFD_GERFL, 0x0);
825825

826-
/* Set the controller into appropriate mode */
827-
rcar_canfd_set_mode(gpriv);
828-
829826
/* Transition all Channels to reset mode */
830827
for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) {
831828
rcar_canfd_clear_bit(gpriv->base,
@@ -844,6 +841,10 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)
844841
return err;
845842
}
846843
}
844+
845+
/* Set the controller into appropriate mode */
846+
rcar_canfd_set_mode(gpriv);
847+
847848
return 0;
848849
}
849850

drivers/net/can/spi/hi311x.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,6 @@ static int hi3110_stop(struct net_device *net)
545545

546546
priv->force_quit = 1;
547547
free_irq(spi->irq, priv);
548-
destroy_workqueue(priv->wq);
549-
priv->wq = NULL;
550548

551549
mutex_lock(&priv->hi3110_lock);
552550

@@ -770,34 +768,23 @@ static int hi3110_open(struct net_device *net)
770768
goto out_close;
771769
}
772770

773-
priv->wq = alloc_workqueue("hi3110_wq", WQ_FREEZABLE | WQ_MEM_RECLAIM,
774-
0);
775-
if (!priv->wq) {
776-
ret = -ENOMEM;
777-
goto out_free_irq;
778-
}
779-
INIT_WORK(&priv->tx_work, hi3110_tx_work_handler);
780-
INIT_WORK(&priv->restart_work, hi3110_restart_work_handler);
781-
782771
ret = hi3110_hw_reset(spi);
783772
if (ret)
784-
goto out_free_wq;
773+
goto out_free_irq;
785774

786775
ret = hi3110_setup(net);
787776
if (ret)
788-
goto out_free_wq;
777+
goto out_free_irq;
789778

790779
ret = hi3110_set_normal_mode(spi);
791780
if (ret)
792-
goto out_free_wq;
781+
goto out_free_irq;
793782

794783
netif_wake_queue(net);
795784
mutex_unlock(&priv->hi3110_lock);
796785

797786
return 0;
798787

799-
out_free_wq:
800-
destroy_workqueue(priv->wq);
801788
out_free_irq:
802789
free_irq(spi->irq, priv);
803790
hi3110_hw_sleep(spi);
@@ -812,6 +799,7 @@ static const struct net_device_ops hi3110_netdev_ops = {
812799
.ndo_open = hi3110_open,
813800
.ndo_stop = hi3110_stop,
814801
.ndo_start_xmit = hi3110_hard_start_xmit,
802+
.ndo_change_mtu = can_change_mtu,
815803
};
816804

817805
static const struct ethtool_ops hi3110_ethtool_ops = {
@@ -908,6 +896,15 @@ static int hi3110_can_probe(struct spi_device *spi)
908896
if (ret)
909897
goto out_clk;
910898

899+
priv->wq = alloc_workqueue("hi3110_wq", WQ_FREEZABLE | WQ_MEM_RECLAIM,
900+
0);
901+
if (!priv->wq) {
902+
ret = -ENOMEM;
903+
goto out_clk;
904+
}
905+
INIT_WORK(&priv->tx_work, hi3110_tx_work_handler);
906+
INIT_WORK(&priv->restart_work, hi3110_restart_work_handler);
907+
911908
priv->spi = spi;
912909
mutex_init(&priv->hi3110_lock);
913910

@@ -943,6 +940,8 @@ static int hi3110_can_probe(struct spi_device *spi)
943940
return 0;
944941

945942
error_probe:
943+
destroy_workqueue(priv->wq);
944+
priv->wq = NULL;
946945
hi3110_power_enable(priv->power, 0);
947946

948947
out_clk:
@@ -963,6 +962,9 @@ static void hi3110_can_remove(struct spi_device *spi)
963962

964963
hi3110_power_enable(priv->power, 0);
965964

965+
destroy_workqueue(priv->wq);
966+
priv->wq = NULL;
967+
966968
clk_disable_unprepare(priv->clk);
967969

968970
free_candev(net);

drivers/net/can/sun4i_can.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ static const struct net_device_ops sun4ican_netdev_ops = {
768768
.ndo_open = sun4ican_open,
769769
.ndo_stop = sun4ican_close,
770770
.ndo_start_xmit = sun4ican_start_xmit,
771+
.ndo_change_mtu = can_change_mtu,
771772
};
772773

773774
static const struct ethtool_ops sun4ican_ethtool_ops = {

drivers/net/can/usb/etas_es58x/es58x_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved.
99
* Copyright (c) 2020 ETAS K.K.. All rights reserved.
10-
* Copyright (c) 2020-2022 Vincent Mailhol <mailhol[email protected]>
10+
* Copyright (c) 2020-2025 Vincent Mailhol <mailhol@kernel.org>
1111
*/
1212

1313
#include <linux/unaligned.h>
@@ -1977,6 +1977,7 @@ static const struct net_device_ops es58x_netdev_ops = {
19771977
.ndo_stop = es58x_stop,
19781978
.ndo_start_xmit = es58x_start_xmit,
19791979
.ndo_eth_ioctl = can_eth_ioctl_hwts,
1980+
.ndo_change_mtu = can_change_mtu,
19801981
};
19811982

19821983
static const struct ethtool_ops es58x_ethtool_ops = {

drivers/net/can/usb/mcba_usb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ static const struct net_device_ops mcba_netdev_ops = {
761761
.ndo_open = mcba_usb_open,
762762
.ndo_stop = mcba_usb_close,
763763
.ndo_start_xmit = mcba_usb_start_xmit,
764+
.ndo_change_mtu = can_change_mtu,
764765
};
765766

766767
static const struct ethtool_ops mcba_ethtool_ops = {

drivers/net/can/usb/peak_usb/pcan_usb_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now)
111111
u32 delta_ts = time_ref->ts_dev_2 - time_ref->ts_dev_1;
112112

113113
if (time_ref->ts_dev_2 < time_ref->ts_dev_1)
114-
delta_ts &= (1 << time_ref->adapter->ts_used_bits) - 1;
114+
delta_ts &= (1ULL << time_ref->adapter->ts_used_bits) - 1;
115115

116116
time_ref->ts_total += delta_ts;
117117
}

0 commit comments

Comments
 (0)