Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5b8c221 authored by Vignesh Kulothungan's avatar Vignesh Kulothungan Committed by Gerrit - the friendly Code Review server
Browse files

rtac: add error check for misc device register



Add error check to validate the return value of
miscellaneous device register.
Clean up memory on an error to avoid memory leak.

CRs-Fixed: 2204093
Change-Id: I8b94bacdc312fa410a7825c7e25764517469c19b
Signed-off-by: default avatarVignesh Kulothungan <vigneshk@codeaurora.org>
parent e60daac3
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1944,17 +1944,26 @@ int __init rtac_init(void)
		goto nomem;
	}

	return misc_register(&rtac_misc);
	if (misc_register(&rtac_misc) != 0) {
		kzfree(rtac_adm_buffer);
		kzfree(rtac_asm_buffer);
		kzfree(rtac_afe_buffer);
		kzfree(rtac_voice_buffer);
		goto nomem;
	}

	return 0;
nomem:
	return -ENOMEM;
}

void rtac_exit(void)
{
	misc_deregister(&rtac_misc);
	kzfree(rtac_adm_buffer);
	kzfree(rtac_asm_buffer);
	kzfree(rtac_afe_buffer);
	misc_deregister(&rtac_misc);
	kzfree(rtac_voice_buffer);
}

MODULE_DESCRIPTION("SoC QDSP6v2 Real-Time Audio Calibration driver");