Unverified Commit 88a94721 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mark Brown
Browse files

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221021190018.63646-2-andriy.shevchenko@linux.intel.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4194dabe
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -229,6 +229,7 @@ enum pxa_ssp_type {
	LPSS_SPT_SSP,
	LPSS_BXT_SSP,
	LPSS_CNL_SSP,
	SSP_MAX
};

struct ssp_device {