Commit 548b9f03 authored by Ivan Bornyakov's avatar Ivan Bornyakov Committed by Greg Kroah-Hartman

staging: gasket: sysfs: fix potential null dereference

Add handling of possible allocation failure.

Reported by smatch:

  drivers/staging/gasket/gasket_sysfs.c:105 put_mapping() error: potential null dereference 'files_to_remove'. (kcalloc returns null)
Signed-off-by: default avatarIvan Bornyakov <brnkv.i1@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c0f460ff
...@@ -101,6 +101,11 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping) ...@@ -101,6 +101,11 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping)
files_to_remove = kcalloc(num_files_to_remove, files_to_remove = kcalloc(num_files_to_remove,
sizeof(*files_to_remove), sizeof(*files_to_remove),
GFP_KERNEL); GFP_KERNEL);
if (!files_to_remove) {
mutex_unlock(&mapping->mutex);
return;
}
for (i = 0; i < num_files_to_remove; i++) 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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment