aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArvind Yadav <arvind.yadav.cs@gmail.com>2017-06-20 05:30:53 -0400
committerMark Brown <broonie@kernel.org>2017-06-28 15:16:41 -0400
commit704c3098e4c55a409eaf5ec89cee1bccc8d44f4c (patch)
treebc3eaa8bed4cff6a5b40eff96f2ba1d691875711
parent478de2ba0d2dafcd460b17f032139e2b6b4eb1ac (diff)
spi: loopback-test: Fix kfree() NULL pointer error.
Here, rx/tx allocation can fail. So avoid kvfree call with NULL pointer. Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi-loopback-test.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c
index 514997a143dc..3459965004f8 100644
--- a/drivers/spi/spi-loopback-test.c
+++ b/drivers/spi/spi-loopback-test.c
@@ -1021,10 +1021,9 @@ int spi_test_run_tests(struct spi_device *spi,
1021 rx = vmalloc(SPI_TEST_MAX_SIZE_PLUS); 1021 rx = vmalloc(SPI_TEST_MAX_SIZE_PLUS);
1022 else 1022 else
1023 rx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL); 1023 rx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL);
1024 if (!rx) { 1024 if (!rx)
1025 ret = -ENOMEM; 1025 return -ENOMEM;
1026 goto out; 1026
1027 }
1028 1027
1029 if (use_vmalloc) 1028 if (use_vmalloc)
1030 tx = vmalloc(SPI_TEST_MAX_SIZE_PLUS); 1029 tx = vmalloc(SPI_TEST_MAX_SIZE_PLUS);
@@ -1032,7 +1031,7 @@ int spi_test_run_tests(struct spi_device *spi,
1032 tx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL); 1031 tx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL);
1033 if (!tx) { 1032 if (!tx) {
1034 ret = -ENOMEM; 1033 ret = -ENOMEM;
1035 goto out; 1034 goto err_tx;
1036 } 1035 }
1037 1036
1038 /* now run the individual tests in the table */ 1037 /* now run the individual tests in the table */
@@ -1057,8 +1056,9 @@ int spi_test_run_tests(struct spi_device *spi,
1057 } 1056 }
1058 1057
1059out: 1058out:
1060 kvfree(rx);
1061 kvfree(tx); 1059 kvfree(tx);
1060err_tx:
1061 kvfree(rx);
1062 return ret; 1062 return ret;
1063} 1063}
1064EXPORT_SYMBOL_GPL(spi_test_run_tests); 1064EXPORT_SYMBOL_GPL(spi_test_run_tests);