[PATCHv2] android/hal-audio: Fix memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>

Fixes clang warning:
...
android/hal-audio.c:484:3: warning: Potential leak of memory pointed to
by 'preset'
...
---
 android/hal-audio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/android/hal-audio.c b/android/hal-audio.c
index 439b583..83ea739 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -482,7 +482,7 @@ static bool open_endpoint(struct audio_endpoint **epp,
 
 	if (!ep) {
 		error("Cound not find opened endpoint");
-		return false;
+		goto failed;
 	}
 
 	*epp = ep;
@@ -516,7 +516,8 @@ static bool open_endpoint(struct audio_endpoint **epp,
 	return true;
 
 failed:
-	close(fd);
+	if (fd >= 0)
+		close(fd);
 	free(preset);
 
 	return false;
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux