Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: altera: Fix memory leak on error path

Release master that have been previously allocated if the number of
chipselect is invalid.

Fixes: 8e04187c1bc7 ("spi: altera: add SPI core parameters support via platform data.")
Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20210120082635.49304-1-bianpan2016@163.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Pan Bian and committed by
Mark Brown
55a8b42e 4d163ad7

+2 -1
+2 -1
drivers/spi/spi-altera.c
··· 254 254 dev_err(&pdev->dev, 255 255 "Invalid number of chipselect: %hu\n", 256 256 pdata->num_chipselect); 257 - return -EINVAL; 257 + err = -EINVAL; 258 + goto exit; 258 259 } 259 260 260 261 master->num_chipselect = pdata->num_chipselect;