]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
firmware: arm_scmi: Fix NULL dereference on notify error path
authorCristian Marussi <cristian.marussi@arm.com>
Thu, 5 Mar 2026 13:10:11 +0000 (13:10 +0000)
committerSudeep Holla <sudeep.holla@kernel.org>
Sat, 7 Mar 2026 19:49:52 +0000 (19:49 +0000)
Since commit b5daf93b809d1 ("firmware: arm_scmi: Avoid notifier
registration for unsupported events") the call chains leading to the helper
__scmi_event_handler_get_ops expect an ERR_PTR to be returned on failure to
get an handler for the requested event key, while the current helper can
still return a NULL when no handler could be found or created.

Fix by forcing an ERR_PTR return value when the handler reference is NULL.

Fixes: b5daf93b809d1 ("firmware: arm_scmi: Avoid notifier registration for unsupported events")
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Message-Id: <20260305131011.541444-1-cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
drivers/firmware/arm_scmi/notify.c

index 9168794adae43b550ab18c009cd82b1631db271a..40ec184eedaecc31c9f8b67c607dfbaae23fc911 100644 (file)
@@ -1066,7 +1066,7 @@ static int scmi_register_event_handler(struct scmi_notify_instance *ni,
  * since at creation time we usually want to have all setup and ready before
  * events really start flowing.
  *
- * Return: A properly refcounted handler on Success, NULL on Failure
+ * Return: A properly refcounted handler on Success, ERR_PTR on Failure
  */
 static inline struct scmi_event_handler *
 __scmi_event_handler_get_ops(struct scmi_notify_instance *ni,
@@ -1113,7 +1113,7 @@ __scmi_event_handler_get_ops(struct scmi_notify_instance *ni,
        }
        mutex_unlock(&ni->pending_mtx);
 
-       return hndl;
+       return hndl ?: ERR_PTR(-ENODEV);
 }
 
 static struct scmi_event_handler *