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

Commit a81d6789 authored by Todd Poynor's avatar Todd Poynor Committed by Greg Kroah-Hartman
Browse files

staging: gasket: sysfs: clean up state if ENOMEM removing mapping



If kcalloc() returns NULL in put_mapping(), continue to clean up state,
including dropping the reference on the struct device and free attribute
memory.

Signed-off-by: default avatarTodd Poynor <toddpoynor@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2bc75964
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -101,13 +101,12 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping)
		files_to_remove = kcalloc(num_files_to_remove,
					  sizeof(*files_to_remove),
					  GFP_KERNEL);
		if (!files_to_remove) {
			mutex_unlock(&mapping->mutex);
			return;
		}

		if (files_to_remove)
			for (i = 0; i < num_files_to_remove; i++)
			files_to_remove[i] = mapping->attributes[i].attr;
				files_to_remove[i] =
				    mapping->attributes[i].attr;
		else
			num_files_to_remove = 0;

		kfree(mapping->attributes);
		mapping->attributes = NULL;