Unverified Commit fec0ddb7 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!11823 mmc: mmc_test: Fix NULL dereference on allocation failure

parents abf23d62 5c1de9f7
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -3104,13 +3104,13 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,
	test->buffer = kzalloc(BUFFER_SIZE, GFP_KERNEL);
#ifdef CONFIG_HIGHMEM
	test->highmem = alloc_pages(GFP_KERNEL | __GFP_HIGHMEM, BUFFER_ORDER);
	if (!test->highmem) {
		count = -ENOMEM;
		goto free_test_buffer;
	}
#endif

#ifdef CONFIG_HIGHMEM
	if (test->buffer && test->highmem) {
#else
	if (test->buffer) {
#endif
		mutex_lock(&mmc_test_lock);
		mmc_test_run(test, testcase);
		mutex_unlock(&mmc_test_lock);
@@ -3118,6 +3118,7 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,

#ifdef CONFIG_HIGHMEM
	__free_pages(test->highmem, BUFFER_ORDER);
free_test_buffer:
#endif
	kfree(test->buffer);
	kfree(test);