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

Commit 8f252290 authored by Dan Carpenter's avatar Dan Carpenter Committed by Jiri Kosina
Browse files

HID: hid-lg4ff: add a kfree() to an error path



There is a small rare potential memory leak here.  Also Walter Harms
points out that we can do a small cleanup as well by using kstrdup().

Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 2bbaf771
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -435,12 +435,12 @@ int lg4ff_init(struct hid_device *hid)
		hid_err(hid, "Cannot add device, insufficient memory.\n");
		return -ENOMEM;
	}
	entry->device_id = (char *)kzalloc(strlen((&hid->dev)->kobj.name) + 1, GFP_KERNEL);
	entry->device_id = kstrdup((&hid->dev)->kobj.name, GFP_KERNEL);
	if (!entry->device_id) {
		hid_err(hid, "Cannot set device_id, insufficient memory.\n");
		kfree(entry);
		return -ENOMEM;
	}
	strcpy(entry->device_id, (&hid->dev)->kobj.name);
	entry->min_range = lg4ff_devices[i].min_range;
	entry->max_range = lg4ff_devices[i].max_range;
	entry->set_range = lg4ff_devices[i].set_range;