spi: dw: Avoid BUG_ON() in case of host failure

If dws is NULL in dw_spi_host_add(), we return the error to the
upper callers instead of crashing. The patch replaces BUG_ON by
returning -EINVAL to the caller.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Link: https://lore.kernel.org/r/20191205231421.9333-1-pakki001@umn.edu
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Aditya Pakki 2019-12-05 17:14:21 -06:00 committed by Mark Brown
parent 4a07b8bcd5
commit 169f9acae0
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 2 additions and 1 deletions

View File

@ -460,7 +460,8 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
struct spi_controller *master; struct spi_controller *master;
int ret; int ret;
BUG_ON(dws == NULL); if (!dws)
return -EINVAL;
master = spi_alloc_master(dev, 0); master = spi_alloc_master(dev, 0);
if (!master) if (!master)