d7933094261c5e627739932ce755a19dcf1952b4
[openwrt/staging/neocturne.git] /
1 From 8c751e0d9a5264376935a84429a2d468c8877d99 Mon Sep 17 00:00:00 2001
2 From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 Date: Sun, 20 Feb 2022 15:15:17 +0000
4 Subject: [PATCH] nvmem: core: Check input parameter for NULL in
5 nvmem_unregister()
6
7 nvmem_unregister() frees resources and standard pattern is to allow
8 caller to not care if it's NULL or not. This will reduce burden on
9 the callers to perform this check.
10
11 Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
12 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
13 Link: https://lore.kernel.org/r/20220220151527.17216-4-srinivas.kandagatla@linaro.org
14 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
15 ---
16 drivers/nvmem/core.c | 3 ++-
17 1 file changed, 2 insertions(+), 1 deletion(-)
18
19 --- a/drivers/nvmem/core.c
20 +++ b/drivers/nvmem/core.c
21 @@ -900,7 +900,8 @@ static void nvmem_device_release(struct
22 */
23 void nvmem_unregister(struct nvmem_device *nvmem)
24 {
25 - kref_put(&nvmem->refcnt, nvmem_device_release);
26 + if (nvmem)
27 + kref_put(&nvmem->refcnt, nvmem_device_release);
28 }
29 EXPORT_SYMBOL_GPL(nvmem_unregister);
30