aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/gasket
diff options
context:
space:
mode:
authorTodd Poynor <toddpoynor@google.com>2018-08-05 13:07:35 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-08-08 11:20:06 +0200
commita81d678949471d5b7f399cfcf2e48e0382427805 (patch)
tree669e5a74bc7885ad1bc34a570d6fbcdc7a979071 /drivers/staging/gasket
parentstaging: erofs: fix if assignment style issue (diff)
downloadlinux-dev-a81d678949471d5b7f399cfcf2e48e0382427805.tar.xz
linux-dev-a81d678949471d5b7f399cfcf2e48e0382427805.zip
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: Todd Poynor <toddpoynor@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/gasket')
-rw-r--r--drivers/staging/gasket/gasket_sysfs.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c
index 56d62aea5111..fc45f0d13e87 100644
--- a/drivers/staging/gasket/gasket_sysfs.c
+++ b/drivers/staging/gasket/gasket_sysfs.c
@@ -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;
- }
-
- for (i = 0; i < num_files_to_remove; i++)
- files_to_remove[i] = mapping->attributes[i].attr;
+ if (files_to_remove)
+ for (i = 0; i < num_files_to_remove; i++)
+ files_to_remove[i] =
+ mapping->attributes[i].attr;
+ else
+ num_files_to_remove = 0;
kfree(mapping->attributes);
mapping->attributes = NULL;