Skip to content

Commit fe9db43

Browse files
jimcgregkh
authored andcommitted
dyndbg: fix use before null check
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>
1 parent 771b663 commit fe9db43

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎lib/dynamic_debug.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,14 @@ static int ddebug_exec_queries(char *query, const char *modname)
561561
int dynamic_debug_exec_queries(const char *query, const char *modname)
562562
{
563563
int rc;
564-
char *qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL);
564+
char *qry; /* writable copy of query */
565565

566-
if (!query)
566+
if (!query) {
567+
pr_err("non-null query/command string expected\n");
568+
return -EINVAL;
569+
}
570+
qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL);
571+
if (!qry)
567572
return -ENOMEM;
568573

569574
rc = ddebug_exec_queries(qry, modname);

0 commit comments

Comments
 (0)