diff options
author | Andy Shevchenko | 2022-02-20 15:15:17 +0000 |
---|---|---|
committer | Greg Kroah-Hartman | 2022-02-21 18:00:29 +0100 |
commit | 8c751e0d9a5264376935a84429a2d468c8877d99 (patch) | |
tree | ef0f27a3d167b165c65f0cef996e5fa4e7d7635b /drivers/nvmem | |
parent | 5825b2c6762611e67ccaf3ccf64485365a120f0b (diff) |
nvmem: core: Check input parameter for NULL in nvmem_unregister()
nvmem_unregister() frees resources and standard pattern is to allow
caller to not care if it's NULL or not. This will reduce burden on
the callers to perform this check.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220220151527.17216-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/nvmem')
-rw-r--r-- | drivers/nvmem/core.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 68db7d3303ac..53a43d843743 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -903,7 +903,8 @@ static void nvmem_device_release(struct kref *kref) */ void nvmem_unregister(struct nvmem_device *nvmem) { - kref_put(&nvmem->refcnt, nvmem_device_release); + if (nvmem) + kref_put(&nvmem->refcnt, nvmem_device_release); } EXPORT_SYMBOL_GPL(nvmem_unregister); |