[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20180801183744.30293-1-brnkv.i1@gmail.com>
Date: Wed, 1 Aug 2018 21:37:44 +0300
From: Ivan Bornyakov <brnkv.i1@...il.com>
To: devel@...verdev.osuosl.org
Cc: linux-kernel@...r.kernel.org, gregkh@...uxfoundation.org,
benchan@...omium.org, jnjoseph@...gle.com, rspringer@...gle.com,
Ivan Bornyakov <brnkv.i1@...il.com>
Subject: [PATCH v2] 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: Ivan Bornyakov <brnkv.i1@...il.com>
---
drivers/staging/gasket/gasket_sysfs.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c
index a4bfca43cd03..56d62aea5111 100644
--- a/drivers/staging/gasket/gasket_sysfs.c
+++ b/drivers/staging/gasket/gasket_sysfs.c
@@ -101,6 +101,11 @@ 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;
--
2.16.4
Powered by blists - more mailing lists