summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-pxa2xx.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2022-10-21 21:00:15 +0200
committerMark Brown <broonie@kernel.org>2022-10-24 14:30:15 +0200
commit88a947215c29aa49307c8cd0638ba54e4cf07391 (patch)
treefd4c29a049386be788afb918cbd726e22e1a11ab /drivers/spi/spi-pxa2xx.c
parentspi: amlogic: meson-spicc: Use pinctrl to drive CLK line when idle (diff)
downloadlinux-88a947215c29aa49307c8cd0638ba54e4cf07391.tar.xz
linux-88a947215c29aa49307c8cd0638ba54e4cf07391.zip
spi: pxa2xx: Validate the correctness of the SSP type
Currently we blindly apply the SSP type value from any source of the information. Increase robustness by validating the value before use. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20221021190018.63646-2-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-pxa2xx.c')
-rw-r--r--drivers/spi/spi-pxa2xx.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index c9f6a3fbe62f..93be7e8ef884 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1460,7 +1460,7 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
struct resource *res;
struct pci_dev *pcidev = dev_is_pci(parent) ? to_pci_dev(parent) : NULL;
const struct pci_device_id *pcidev_id = NULL;
- enum pxa_ssp_type type;
+ enum pxa_ssp_type type = SSP_UNDEFINED;
const void *match;
int status;
u64 uid;
@@ -1473,7 +1473,9 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
type = (enum pxa_ssp_type)match;
else if (pcidev_id)
type = (enum pxa_ssp_type)pcidev_id->driver_data;
- else
+
+ /* Validate the SSP type correctness */
+ if (!(type > SSP_UNDEFINED && type < SSP_MAX))
return ERR_PTR(-EINVAL);
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);