Skip to content

Commit 6b8526d

Browse files
committed
ipmi:ssif: Handle a possible NULL pointer reference
In error cases a NULL can be passed to memcpy. The length will always be zero, so it doesn't really matter, but go ahead and check for NULL, anyway, to be more precise and avoid static analysis errors. Reported-by: kbuild test robot <[email protected]> Signed-off-by: Corey Minyard <[email protected]>
1 parent 380665b commit 6b8526d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/char/ipmi/ipmi_ssif.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,10 +775,14 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
775775
flags = ipmi_ssif_lock_cond(ssif_info, &oflags);
776776
msg = ssif_info->curr_msg;
777777
if (msg) {
778+
if (data) {
779+
if (len > IPMI_MAX_MSG_LENGTH)
780+
len = IPMI_MAX_MSG_LENGTH;
781+
memcpy(msg->rsp, data, len);
782+
} else {
783+
len = 0;
784+
}
778785
msg->rsp_size = len;
779-
if (msg->rsp_size > IPMI_MAX_MSG_LENGTH)
780-
msg->rsp_size = IPMI_MAX_MSG_LENGTH;
781-
memcpy(msg->rsp, data, msg->rsp_size);
782786
ssif_info->curr_msg = NULL;
783787
}
784788

0 commit comments

Comments
 (0)