From: Jag Raman Date: Fri, 23 Jun 2017 18:58:37 +0000 (-0400) Subject: sparc64: check if a client is allowed to register for MDESC notifications X-Git-Tag: v4.13-rc1~93^2~2^2~3 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=110f2264b37674e99057acd249a930040fad55b1;p=karo-tx-linux.git sparc64: check if a client is allowed to register for MDESC notifications Check if a client is supported, by comparing against a whitelist, to register for notifications from Machine Description (MDESC) Signed-off-by: Jagannathan Raman Reviewed-by: Liam Merwick Reviewed-by: Shannon Nelson Signed-off-by: David S. Miller --- diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c index 04b76267ddfa..f795ee015738 100644 --- a/arch/sparc/kernel/mdesc.c +++ b/arch/sparc/kernel/mdesc.c @@ -284,9 +284,26 @@ static struct mdesc_notifier_client *client_list; void mdesc_register_notifier(struct mdesc_notifier_client *client) { + bool supported = false; u64 node; + int i; mutex_lock(&mdesc_mutex); + + /* check to see if the node is supported for registration */ + for (i = 0; md_node_ops_table[i].name != NULL; i++) { + if (strcmp(md_node_ops_table[i].name, client->node_name) == 0) { + supported = true; + break; + } + } + + if (!supported) { + pr_err("MD: %s node not supported\n", client->node_name); + mutex_unlock(&mdesc_mutex); + return; + } + client->next = client_list; client_list = client;