Commit f990874
ieee802154: ca8210: Fix a potential UAF in ca8210_probe
If of_clk_add_provider() fails in ca8210_register_ext_clock(),
it calls clk_unregister() to release priv->clk and returns an
error. However, the caller ca8210_probe() then calls ca8210_remove(),
where priv->clk is freed again in ca8210_unregister_ext_clock(). In
this case, a use-after-free may happen in the second time we call
clk_unregister().
Fix this by removing the first clk_unregister(). Also, priv->clk could
be an error code on failure of clk_register_fixed_rate(). Use
IS_ERR_OR_NULL to catch this case in ca8210_unregister_ext_clock().
Fixes: ded845a ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Message-ID: <20231007033049.22353-1-dinghao.liu@zju.edu.cn>
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>1 parent a2e5255 commit f990874
1 file changed
Lines changed: 3 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2740 | 2740 | | |
2741 | 2741 | | |
2742 | 2742 | | |
2743 | | - | |
2744 | 2743 | | |
2745 | 2744 | | |
2746 | 2745 | | |
| |||
2757 | 2756 | | |
2758 | 2757 | | |
2759 | 2758 | | |
2760 | | - | |
2761 | | - | |
2762 | | - | |
2763 | | - | |
2764 | | - | |
2765 | | - | |
2766 | | - | |
2767 | | - | |
2768 | | - | |
2769 | | - | |
2770 | 2759 | | |
2771 | | - | |
| 2760 | + | |
2772 | 2761 | | |
2773 | 2762 | | |
2774 | 2763 | | |
| |||
2780 | 2769 | | |
2781 | 2770 | | |
2782 | 2771 | | |
2783 | | - | |
2784 | | - | |
| 2772 | + | |
| 2773 | + | |
2785 | 2774 | | |
2786 | 2775 | | |
2787 | 2776 | | |
| |||
0 commit comments