Blame SOURCES/0004-sixaxis-Fix-memory-leaks.patch

150e62
From fc57aa92a4f32f7c0f38198e6d26b529b537a047 Mon Sep 17 00:00:00 2001
150e62
From: Gopal Tiwari <gtiwari@redhat.com>
150e62
Date: Tue, 31 May 2022 13:11:08 +0530
150e62
Subject: [PATCH BlueZ 04/12] sixaxis: Fix memory leaks
150e62
150e62
While performing static tool analysis using coverity
150e62
found following reports for resouse leak
150e62
150e62
bluez-5.64/plugins/sixaxis.c:425: alloc_arg:
150e62
"get_pairing_type_for_device" allocates memory that is
150e62
stored into "sysfs_path".
150e62
150e62
bluez-5.64/plugins/sixaxis.c:428: leaked_storage: Variable "sysfs_path"
150e62
going out of scope leaks the storage it points to.
150e62
---
150e62
 plugins/sixaxis.c | 9 +++++++--
150e62
 1 file changed, 7 insertions(+), 2 deletions(-)
150e62
150e62
diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
150e62
index ddecbcccb..10cf15948 100644
150e62
--- a/plugins/sixaxis.c
150e62
+++ b/plugins/sixaxis.c
150e62
@@ -424,10 +424,15 @@ static void device_added(struct udev_device *udevice)
150e62
 
150e62
 	cp = get_pairing_type_for_device(udevice, &bus, &sysfs_path);
150e62
 	if (!cp || (cp->type != CABLE_PAIRING_SIXAXIS &&
150e62
-				cp->type != CABLE_PAIRING_DS4))
150e62
+				cp->type != CABLE_PAIRING_DS4)) {
150e62
+		g_free(sysfs_path);
150e62
 		return;
150e62
-	if (bus != BUS_USB)
150e62
+	}
150e62
+
150e62
+	if (bus != BUS_USB) {
150e62
+		g_free(sysfs_path);
150e62
 		return;
150e62
+	}
150e62
 
150e62
 	info("sixaxis: compatible device connected: %s (%04X:%04X %s)",
150e62
 				cp->name, cp->vid, cp->pid, sysfs_path);
150e62
-- 
150e62
2.26.2
150e62