staging: gasket: Remove stale pointers on error allocating attr array
authorTodd Poynor <toddpoynor@google.com>
Tue, 17 Jul 2018 20:56:48 +0000 (13:56 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jul 2018 09:39:47 +0000 (11:39 +0200)
If gasket_sysfs_create_mapping() hits errors allocating the attribute
array, remove stale pointers to device info from the mapping object.

Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/gasket/gasket_sysfs.c

index dd4d3aaa57e2fe8e9683c0c51cb31d8c4366311f..1c5f7502e0d5ec9dd97a65b701a30730462e5336 100644 (file)
@@ -225,6 +225,8 @@ int gasket_sysfs_create_mapping(
        mapping->attribute_count = 0;
        if (!mapping->attributes) {
                gasket_nodev_error("Unable to allocate sysfs attribute array.");
+               mapping->device = NULL;
+               mapping->gasket_dev = NULL;
                mutex_unlock(&mapping->mutex);
                mutex_unlock(&function_mutex);
                return -ENOMEM;