Skip to content

Commit

Permalink
intel_punit_ipc: add NULL check for input parameters
Browse files Browse the repository at this point in the history
intel_punit_ipc_command() maybe called when in or out
data pointers are NULL.

Signed-off-by: Qipeng Zha <[email protected]>
Signed-off-by: Darren Hart <[email protected]>
  • Loading branch information
qipengzha authored and dvhart committed Jan 20, 2016
1 parent bb28f3d commit 3fae757
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions drivers/platform/x86/intel_punit_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,12 @@ int intel_punit_ipc_command(u32 cmd, u32 para1, u32 para2, u32 *in, u32 *out)

reinit_completion(&ipcdev->cmd_complete);
type = (cmd & IPC_PUNIT_CMD_TYPE_MASK) >> IPC_TYPE_OFFSET;
ipc_write_data_low(ipcdev, type, *in);

if (type == GTDRIVER_IPC || type == ISPDRIVER_IPC)
ipc_write_data_high(ipcdev, type, *++in);
if (in) {
ipc_write_data_low(ipcdev, type, *in);
if (type == GTDRIVER_IPC || type == ISPDRIVER_IPC)
ipc_write_data_high(ipcdev, type, *++in);
}

val = cmd & ~IPC_PUNIT_CMD_TYPE_MASK;
val |= CMD_RUN | para2 << CMD_PARA2_SHIFT | para1 << CMD_PARA1_SHIFT;
Expand All @@ -199,10 +201,12 @@ int intel_punit_ipc_command(u32 cmd, u32 para1, u32 para2, u32 *in, u32 *out)
ret = intel_punit_ipc_check_status(ipcdev, type);
if (ret)
goto out;
*out = ipc_read_data_low(ipcdev, type);

if (type == GTDRIVER_IPC || type == ISPDRIVER_IPC)
*++out = ipc_read_data_high(ipcdev, type);
if (out) {
*out = ipc_read_data_low(ipcdev, type);
if (type == GTDRIVER_IPC || type == ISPDRIVER_IPC)
*++out = ipc_read_data_high(ipcdev, type);
}

out:
mutex_unlock(&ipcdev->lock);
Expand Down

0 comments on commit 3fae757

Please sign in to comment.