spi: pxa2xx: Do not override dev->platform_data on probe
The platform_data field may be supplied by legacy board code. In other cases we override it, and module remove and probe cycle will crash the kernel since it will carry a stale pointer. Fix this by supplying a third argument to the pxa2xx_spi_probe() and avoid overriding dev->platform_data. Reported-by: Hao Ma <hao.ma@intel.com> Fixes:cc160697a5
("spi: pxa2xx: Convert PCI driver to use spi-pxa2xx code directly") Fixes:3d8f037fbc
("spi: pxa2xx: Move platform driver to a separate file") Fixes:20ade9b977
("spi: pxa2xx: Extract pxa2xx_spi_platform_*() callbacks") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20240822113408.750831-2-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
783bf5d09f
commit
9a8fc292dd
@ -297,7 +297,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
|
||||
return ret;
|
||||
ssp->irq = pci_irq_vector(dev, 0);
|
||||
|
||||
return pxa2xx_spi_probe(&dev->dev, ssp);
|
||||
return pxa2xx_spi_probe(&dev->dev, ssp, pdata);
|
||||
}
|
||||
|
||||
static void pxa2xx_spi_pci_remove(struct pci_dev *dev)
|
||||
|
@ -63,7 +63,7 @@ static struct ssp_device *pxa2xx_spi_ssp_request(struct platform_device *pdev)
|
||||
|
||||
ssp = pxa_ssp_request(pdev->id, pdev->name);
|
||||
if (!ssp)
|
||||
return ssp;
|
||||
return NULL;
|
||||
|
||||
status = devm_add_action_or_reset(&pdev->dev, pxa2xx_spi_ssp_release, ssp);
|
||||
if (status)
|
||||
@ -148,8 +148,6 @@ static int pxa2xx_spi_platform_probe(struct platform_device *pdev)
|
||||
platform_info = pxa2xx_spi_init_pdata(pdev);
|
||||
if (IS_ERR(platform_info))
|
||||
return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n");
|
||||
|
||||
dev->platform_data = platform_info;
|
||||
}
|
||||
|
||||
ssp = pxa2xx_spi_ssp_request(pdev);
|
||||
@ -158,7 +156,7 @@ static int pxa2xx_spi_platform_probe(struct platform_device *pdev)
|
||||
if (!ssp)
|
||||
ssp = &platform_info->ssp;
|
||||
|
||||
return pxa2xx_spi_probe(dev, ssp);
|
||||
return pxa2xx_spi_probe(dev, ssp, platform_info);
|
||||
}
|
||||
|
||||
static void pxa2xx_spi_platform_remove(struct platform_device *pdev)
|
||||
|
@ -1277,16 +1277,15 @@ static size_t pxa2xx_spi_max_dma_transfer_size(struct spi_device *spi)
|
||||
return MAX_DMA_LEN;
|
||||
}
|
||||
|
||||
int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp)
|
||||
int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp,
|
||||
struct pxa2xx_spi_controller *platform_info)
|
||||
{
|
||||
struct pxa2xx_spi_controller *platform_info;
|
||||
struct spi_controller *controller;
|
||||
struct driver_data *drv_data;
|
||||
const struct lpss_config *config;
|
||||
int status;
|
||||
u32 tmp;
|
||||
|
||||
platform_info = dev_get_platdata(dev);
|
||||
if (platform_info->is_target)
|
||||
controller = devm_spi_alloc_target(dev, sizeof(*drv_data));
|
||||
else
|
||||
|
@ -132,7 +132,8 @@ extern void pxa2xx_spi_dma_stop(struct driver_data *drv_data);
|
||||
extern int pxa2xx_spi_dma_setup(struct driver_data *drv_data);
|
||||
extern void pxa2xx_spi_dma_release(struct driver_data *drv_data);
|
||||
|
||||
int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp);
|
||||
int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp,
|
||||
struct pxa2xx_spi_controller *platform_info);
|
||||
void pxa2xx_spi_remove(struct device *dev);
|
||||
|
||||
extern const struct dev_pm_ops pxa2xx_spi_pm_ops;
|
||||
|
Loading…
Reference in New Issue
Block a user