Skip to content

Commit

Permalink
drivers/misc/pti.c: give 'comm' function scope in pti_control_frame_b…
Browse files Browse the repository at this point in the history
…uilt_and_sent()

In drivers/misc/pti.c::pti_control_frame_built_and_sent() we assign 'comm'
to 'thread_name_p' if (!thread_name).  The problem is that 'comm' then
goes out of scope and later we use 'thread_name_p' which now refers to an
out-of-scope variable.  To fix that, simply move 'comm' up to have
function scope.

Signed-off-by: Jesper Juhl <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: J Freyensee <[email protected]>
Cc: Jeremy Rocher <[email protected]>
Cc: Sergei Trofimovich <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jjuhl authored and torvalds committed Sep 15, 2011
1 parent 83ede96 commit 1ebe9da
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions drivers/misc/pti.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,18 @@ static void pti_write_to_aperture(struct pti_masterchannel *mc,
static void pti_control_frame_built_and_sent(struct pti_masterchannel *mc,
const char *thread_name)
{
/*
* Since we access the comm member in current's task_struct, we only
* need to be as large as what 'comm' in that structure is.
*/
char comm[TASK_COMM_LEN];
struct pti_masterchannel mccontrol = {.master = CONTROL_ID,
.channel = 0};
const char *thread_name_p;
const char *control_format = "%3d %3d %s";
u8 control_frame[CONTROL_FRAME_LEN];

if (!thread_name) {
/*
* Since we access the comm member in current's task_struct,
* we only need to be as large as what 'comm' in that
* structure is.
*/
char comm[TASK_COMM_LEN];

if (!in_interrupt())
get_task_comm(comm, current);
else
Expand Down

0 comments on commit 1ebe9da

Please sign in to comment.