Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp645609ybh; Tue, 10 Mar 2020 05:47:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvr3/r3PyxT67PlFIjJwCNh6dxyrjKxd6Y23VENN8zcyovO8cXv/DLfr9AXGG78JsufXPc4 X-Received: by 2002:a9d:882:: with SMTP id 2mr1894611otf.198.1583844433996; Tue, 10 Mar 2020 05:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583844433; cv=none; d=google.com; s=arc-20160816; b=T4BEWQTAR+mKtj7p8WqFoeU5t0EuZbIMLlt6H0/52BfoHFWSKPrff8/Rn6pi7rPx7r oOlOD4fVqjVcu1LJOUzPXqzYFrDcAFrck2tH/sp9eaBotDFfGDb0VSEyHHHL0AY/B/6N l+da0vNnt8omHg+RvIbfhufG4AH6lV+l2A3zqZ1AzKMDp/GhwjAU1NkSflWfIV0nfOO7 YKyVWkYelmYQGYlUDOVP8xHF2xpIVd/vY0E7dt2Dvnd+vwi1Yh5LXmlNBlkh0qAeW4le 8ARGJVm0xTi0A67OPjMyluHDBScISAILOwn4Qr+dIPv4zBwhaP0BT1cTypkM6h19aYvM prKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=K+m8km8uzoOIVnIPOEY/jiAWcMTuzSUwoJJ4u/x+4iE=; b=tC7Lb9d6SvW4t821pt8mcYpvQ5VZFVdaywyWvvmmdRZp8nRhEBR1FhyPJO04uKcSPj I2Uhr0adtETMpc2eNx+s9+BSwU26nRhrcNjPZg272O2drAFE0imoO3/bwI5vpjlxQ7Q5 t9tzkvtCTs6feSZsw3RHDiazhxVj2LGreAErKsAPhOF4iK7EVHkk1nP4lTF4fUkV8RvX /dH6Lg9+rOwia7RcjQllB9BUrwOpGB1OZModdU6AUcQlZ9VvRbqwt3Sk0tLtcYn4cS9c 7ywNVZWCaZ4rd7Ky2qnxtJOzFPxTAnDBLDa4rMVqw8Z4YjNxZznifHAiz5EAdv3RpXb8 wk5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M2JZ4Gnw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22si5877002oiy.124.2020.03.10.05.47.02; Tue, 10 Mar 2020 05:47:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M2JZ4Gnw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726892AbgCJMpK (ORCPT + 99 others); Tue, 10 Mar 2020 08:45:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:47586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727600AbgCJMpI (ORCPT ); Tue, 10 Mar 2020 08:45:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 16B81246A3; Tue, 10 Mar 2020 12:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583844306; bh=cg2as5AkT77EQDRMH1DPFUeJrfDK/wXOqjs5Sf/uJa8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M2JZ4GnwNJh0ZvzcBhLMkx/PVCz90aHHwelsFm9QU7SmMsGQmpaUJ4E9tLv33RIfn qPZ831E1Sylr+JYDlSJgunTVp5mgP9s44tUFhwNsM3CoIjewA+RzypxiOarnKMF/wI Yg0K25n3M+VeshODXAo6LaJfyZwGNSioG6J9PR6w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kbuild test robot , Corey Minyard , Sasha Levin Subject: [PATCH 4.9 05/88] ipmi:ssif: Handle a possible NULL pointer reference Date: Tue, 10 Mar 2020 13:38:13 +0100 Message-Id: <20200310123608.059439536@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310123606.543939933@linuxfoundation.org> References: <20200310123606.543939933@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Corey Minyard [ 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 Signed-off-by: Corey Minyard Signed-off-by: Sasha Levin --- 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 996b9ae154042..a4ef9a6bd3678 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c @@ -746,10 +746,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