Skip to content

Commit

Permalink
dyndbg: fix use before null check
Browse files Browse the repository at this point in the history
commit 3577afb upstream.

In commit a2d375e ("dyndbg: refine export, rename to
dynamic_debug_exec_queries()"), a string is copied before checking it
isn't NULL.  Fix this, report a usage/interface error, and return the
proper error code.

Fixes: a2d375e ("dyndbg: refine export, rename to dynamic_debug_exec_queries()")
Cc: stable@vger.kernel.org
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Link: https://lore.kernel.org/r/20201209183625.2432329-1-jim.cromie@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
jimc authored and gregkh committed Dec 30, 2020
1 parent 771b663 commit fe9db43
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/dynamic_debug.c
Expand Up @@ -561,9 +561,14 @@ static int ddebug_exec_queries(char *query, const char *modname)
int dynamic_debug_exec_queries(const char *query, const char *modname)
{
int rc;
char *qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL);
char *qry; /* writable copy of query */

if (!query)
if (!query) {
pr_err("non-null query/command string expected\n");
return -EINVAL;
}
qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL);
if (!qry)
return -ENOMEM;

rc = ddebug_exec_queries(qry, modname);
Expand Down

0 comments on commit fe9db43

Please sign in to comment.