diff mbox series

[v2,3/5] nvmem: core: Check input parameter for NULL in nvmem_unregister()

Message ID 20220124180040.50660-3-andriy.shevchenko@linux.intel.com
State New
Headers show
Series [v2,1/5] nvmem: core: Remove unused devm_nvmem_unregister() | expand

Commit Message

Andy Shevchenko Jan. 24, 2022, 6 p.m. UTC
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>
---
v2: no changes
 drivers/nvmem/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

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);