Commit 8700af2
RDMA/rtrs-clt: Fix possible double free in error case
Callback function rtrs_clt_dev_release() for put_device() calls kfree(clt)
to free memory. We shouldn't call kfree(clt) again, and we can't use the
clt after kfree too.
Replace device_register() with device_initialize() and device_add() so that
dev_set_name can() be used appropriately.
Move mutex_destroy() to the release function so it can be called in
the alloc_clt err path.
Fixes: eab0982 ("RDMA/rtrs-clt: Refactor the failure cases in alloc_clt")
Link: https://lore.kernel.org/r/20220217030929.323849-1-haris.iqbal@ionos.com
Reported-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Reviewed-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>1 parent 32f57cb commit 8700af2
1 file changed
Lines changed: 20 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2682 | 2682 | | |
2683 | 2683 | | |
2684 | 2684 | | |
| 2685 | + | |
| 2686 | + | |
2685 | 2687 | | |
2686 | 2688 | | |
2687 | 2689 | | |
| |||
2711 | 2713 | | |
2712 | 2714 | | |
2713 | 2715 | | |
| 2716 | + | |
| 2717 | + | |
2714 | 2718 | | |
2715 | 2719 | | |
2716 | 2720 | | |
| |||
2727 | 2731 | | |
2728 | 2732 | | |
2729 | 2733 | | |
| 2734 | + | |
2730 | 2735 | | |
2731 | | - | |
2732 | | - | |
2733 | 2736 | | |
2734 | 2737 | | |
2735 | | - | |
| 2738 | + | |
| 2739 | + | |
2736 | 2740 | | |
2737 | 2741 | | |
2738 | 2742 | | |
2739 | 2743 | | |
2740 | 2744 | | |
2741 | | - | |
2742 | | - | |
2743 | | - | |
2744 | | - | |
2745 | | - | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
2746 | 2748 | | |
2747 | 2749 | | |
2748 | 2750 | | |
2749 | 2751 | | |
2750 | | - | |
| 2752 | + | |
2751 | 2753 | | |
2752 | 2754 | | |
2753 | 2755 | | |
2754 | 2756 | | |
2755 | 2757 | | |
2756 | | - | |
| 2758 | + | |
2757 | 2759 | | |
2758 | 2760 | | |
2759 | 2761 | | |
2760 | 2762 | | |
2761 | 2763 | | |
2762 | | - | |
2763 | | - | |
2764 | | - | |
| 2764 | + | |
| 2765 | + | |
| 2766 | + | |
2765 | 2767 | | |
2766 | | - | |
| 2768 | + | |
2767 | 2769 | | |
2768 | 2770 | | |
2769 | 2771 | | |
2770 | 2772 | | |
2771 | 2773 | | |
2772 | 2774 | | |
2773 | 2775 | | |
2774 | | - | |
2775 | | - | |
2776 | | - | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
2777 | 2780 | | |
2778 | 2781 | | |
2779 | 2782 | | |
| |||
0 commit comments