msm: usb_bam: Fix failure of remove by of_platform_depopulate
If device is created by of_platform_populate and removed by of_platform_depopulate from parent device driver, platform_data will be released twice and lead to kernel panic. of_platform_depopulate will free platform_data of each device driver. Usually we use devm_kzalloc to malloc for platform_data so it can be released during driver unregister. So if device is removed by of_platform_depopulate and platform_data is malloced by devm_kzalloc, platform_data will be freed twice. To fix it, move this data into struct usb_bam_ctx_type and then store usb_bam_ctx_type into device driver data. In this way, it can be get in remove function. The member regs of usb_bam_ctx_type is not necessary. It is only used for ioremap which already has been done by virt_addr of struct sps_bam_props. Without sps_deregister_bam_device, bam child device will not be created again during defer probe. So deregister in remove function. Change-Id: Ibae80745be5810d400a1c05566a99efcc2190020 Signed-off-by:Ziqi Chen <ziqic@codeaurora.org> Signed-off-by:
Mayank Rana <mrana@codeaurora.org>
Loading
Please register or sign in to comment