public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.4 1/7] ipmi:ssif: Handle a possible NULL pointer reference
@ 2020-02-23  2:24 Sasha Levin
  2020-02-23  2:24 ` [PATCH AUTOSEL 4.4 2/7] mac80211: consider more elements in parsing CRC Sasha Levin
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Sasha Levin @ 2020-02-23  2:24 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Corey Minyard, kbuild test robot, Sasha Levin, openipmi-developer

From: Corey Minyard <cminyard@mvista.com>

[ Upstream commit 6b8526d3abc02c08a2f888e8c20b7ac9e5776dfe ]

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 <lkp@intel.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/char/ipmi/ipmi_ssif.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 67d23ed2d1a06..29082d99264e8 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -742,10 +742,14 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
 	flags = ipmi_ssif_lock_cond(ssif_info, &oflags);
 	msg = ssif_info->curr_msg;
 	if (msg) {
+		if (data) {
+			if (len > IPMI_MAX_MSG_LENGTH)
+				len = IPMI_MAX_MSG_LENGTH;
+			memcpy(msg->rsp, data, len);
+		} else {
+			len = 0;
+		}
 		msg->rsp_size = len;
-		if (msg->rsp_size > IPMI_MAX_MSG_LENGTH)
-			msg->rsp_size = IPMI_MAX_MSG_LENGTH;
-		memcpy(msg->rsp, data, msg->rsp_size);
 		ssif_info->curr_msg = NULL;
 	}
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-02-23  2:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-23  2:24 [PATCH AUTOSEL 4.4 1/7] ipmi:ssif: Handle a possible NULL pointer reference Sasha Levin
2020-02-23  2:24 ` [PATCH AUTOSEL 4.4 2/7] mac80211: consider more elements in parsing CRC Sasha Levin
2020-02-23  2:24 ` [PATCH AUTOSEL 4.4 3/7] cfg80211: check wiphy driver existence for drvinfo report Sasha Levin
2020-02-23  2:24 ` [PATCH AUTOSEL 4.4 4/7] arm/ftrace: Fix BE text poking Sasha Levin
2020-02-23  2:24 ` [PATCH AUTOSEL 4.4 5/7] enic: prevent waking up stopped tx queues over watchdog reset Sasha Levin
2020-02-23  2:24 ` [PATCH AUTOSEL 4.4 6/7] cifs: Fix mode output in debugging statements Sasha Levin
2020-02-23  2:24 ` [PATCH AUTOSEL 4.4 7/7] cfg80211: add missing policy for NL80211_ATTR_STATUS_CODE Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox