mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 02:50:43 +00:00
spi: coldfire-qspi: Prevent NULL pointer dereference
If pdata->cs_control is NULL, we will hit NULL pointer dereference in mcfqspi_cs_select() and mcfqspi_cs_deselect(). Thus add NULL test for pdata->cs_control in probe(). Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
2aa237f4a1
commit
2271cf124a
1 changed files with 7 additions and 2 deletions
|
@ -133,13 +133,13 @@ static void mcfqspi_cs_deselect(struct mcfqspi *mcfqspi, u8 chip_select,
|
|||
|
||||
static int mcfqspi_cs_setup(struct mcfqspi *mcfqspi)
|
||||
{
|
||||
return (mcfqspi->cs_control && mcfqspi->cs_control->setup) ?
|
||||
return (mcfqspi->cs_control->setup) ?
|
||||
mcfqspi->cs_control->setup(mcfqspi->cs_control) : 0;
|
||||
}
|
||||
|
||||
static void mcfqspi_cs_teardown(struct mcfqspi *mcfqspi)
|
||||
{
|
||||
if (mcfqspi->cs_control && mcfqspi->cs_control->teardown)
|
||||
if (mcfqspi->cs_control->teardown)
|
||||
mcfqspi->cs_control->teardown(mcfqspi->cs_control);
|
||||
}
|
||||
|
||||
|
@ -372,6 +372,11 @@ static int mcfqspi_probe(struct platform_device *pdev)
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
if (!pdata->cs_control) {
|
||||
dev_dbg(&pdev->dev, "pdata->cs_control is NULL\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
master = spi_alloc_master(&pdev->dev, sizeof(*mcfqspi));
|
||||
if (master == NULL) {
|
||||
dev_dbg(&pdev->dev, "spi_alloc_master failed\n");
|
||||
|
|
Loading…
Reference in a new issue