Commit 6b69680
can: hi311x: fix null pointer dereference when resuming from sleep before interface was enabled
This issue is similar to the vulnerability in the `mcp251x` driver,
which was fixed in commit 03c4271 ("can: mcp251x: fix resume from
sleep before interface was brought up").
In the `hi311x` driver, when the device resumes from sleep, the driver
schedules `priv->restart_work`. However, if the network interface was
not previously enabled, the `priv->wq` (workqueue) is not allocated and
initialized, leading to a null pointer dereference.
To fix this, we move the allocation and initialization of the workqueue
from the `hi3110_open` function to the `hi3110_can_probe` function.
This ensures that the workqueue is properly initialized before it is
used during device resume. And added logic to destroy the workqueue
in the error handling paths of `hi3110_can_probe` and in the
`hi3110_can_remove` function to prevent resource leaks.
Signed-off-by: Chen Yufeng <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Marc Kleine-Budde <[email protected]>1 parent cbf658d commit 6b69680
1 file changed
+17
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
548 | | - | |
549 | | - | |
550 | 548 | | |
551 | 549 | | |
552 | 550 | | |
| |||
770 | 768 | | |
771 | 769 | | |
772 | 770 | | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | 771 | | |
783 | 772 | | |
784 | | - | |
| 773 | + | |
785 | 774 | | |
786 | 775 | | |
787 | 776 | | |
788 | | - | |
| 777 | + | |
789 | 778 | | |
790 | 779 | | |
791 | 780 | | |
792 | | - | |
| 781 | + | |
793 | 782 | | |
794 | 783 | | |
795 | 784 | | |
796 | 785 | | |
797 | 786 | | |
798 | 787 | | |
799 | | - | |
800 | | - | |
801 | 788 | | |
802 | 789 | | |
803 | 790 | | |
| |||
908 | 895 | | |
909 | 896 | | |
910 | 897 | | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
911 | 907 | | |
912 | 908 | | |
913 | 909 | | |
| |||
943 | 939 | | |
944 | 940 | | |
945 | 941 | | |
| 942 | + | |
| 943 | + | |
946 | 944 | | |
947 | 945 | | |
948 | 946 | | |
| |||
963 | 961 | | |
964 | 962 | | |
965 | 963 | | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
966 | 967 | | |
967 | 968 | | |
968 | 969 | | |
| |||
0 commit comments