Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3849092pxb; Tue, 17 Nov 2020 05:20:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwL1pkjzirE8CVXEQdWxABEDT/zcQd5Gtx2fx1hnnmhqVia+j2fAeejq5TTAyJ7vRYkJnuR X-Received: by 2002:a17:906:2e4a:: with SMTP id r10mr18995638eji.266.1605619210416; Tue, 17 Nov 2020 05:20:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605619210; cv=none; d=google.com; s=arc-20160816; b=gNc6DWAmE0xXCS5NJH58UqSR3JoD2UduN8n8GXc01HRk+hkDzlZ76AKVG9+69hRe2u kUMYkq/copoI02IaiWlscipyHUzhltU+6ljcs/6kaBgeJjFrBspzth5VbrGfOnkqVQxX LGi0VDQpQj3yWVO9QUE/qPfDxjQh/ter82Vf6AzUJHy/DOXd6hUDGS+ZpZmmmAQ118Rl 5MQhCRe8K80ts6YP06R+I5dCLNBFQaVoGea8RNfIwL4aCj1BqPwAdyFw7Q2NOVAJ3lBF /IRxxSb2lnBYzQeR35asxaq5F9YKfM8PnC+z5vWL+84ovZbTl9fM6eggNtu2ltAEntX4 M8mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Yd/7wY6CvueE1mfX2NrIw3zAyugK68VjvGxnUDSeCuc=; b=F/xctL1b1w8ygTtvdxNz0oCnYzMpHLf4inhAjxcY0KDpDnyQTZ1zHBS76Y1Dk7c3SK nefKTaD+Ztv9Gjn/DYJNWOc2NbCIc8j9gFN+xw5mJhGk2J12F148C7qzd6WquI7mKn/t v+cvHPEufdEoAcC4nOv13wLfJWLUPEhZ+0+4eKLoifBXs/OpBdmgLMtu6SkMN1APq+iY jZti/0Lj7sHSHFoYeDpgiS8nbNPSFGloxwfY6+4gICo9ZP1bK1TeIxV9eI5bnTFbMCGz VZI8j6BhETcbL1e005QYlCLOD7jape2sDr54TN1qaV/Z7WUfE3ItRdZv4kuTELjyZeSx Mj7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jdn9haYs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si14548632edo.384.2020.11.17.05.19.45; Tue, 17 Nov 2020 05:20:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jdn9haYs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730146AbgKQNPM (ORCPT + 99 others); Tue, 17 Nov 2020 08:15:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:46330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730131AbgKQNPI (ORCPT ); Tue, 17 Nov 2020 08:15:08 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 89343246BB; Tue, 17 Nov 2020 13:15:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605618908; bh=+rgwgfGorZpGwIOPV5zY/fKHJ4P2fVNO+fpHvwOEpZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jdn9haYs1la3d3BI6pXL/8cqALudYZnwQSvPOtJN8/yk2LmXPD+vtrpxDWtxRVQ3O uUBorG7m79wFTR43ZPWmIhjhM6GxaQf3mn8SyEsU/qBV+z80kGgMbMmLNX9l0Pb2YK WhPPw5hRwYpLe0VQzfT8Rx0ZZfalD2Wdolt8jI8M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Usyskin , Tomas Winkler Subject: [PATCH 4.14 49/85] mei: protect mei_cl_mtu from null dereference Date: Tue, 17 Nov 2020 14:05:18 +0100 Message-Id: <20201117122113.434485262@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122111.018425544@linuxfoundation.org> References: <20201117122111.018425544@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Usyskin commit bcbc0b2e275f0a797de11a10eff495b4571863fc upstream. A receive callback is queued while the client is still connected but can still be called after the client was disconnected. Upon disconnect cl->me_cl is set to NULL, hence we need to check that ME client is not-NULL in mei_cl_mtu to avoid null dereference. Cc: Signed-off-by: Alexander Usyskin Signed-off-by: Tomas Winkler Link: https://lore.kernel.org/r/20201029095444.957924-2-tomas.winkler@intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/misc/mei/client.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/misc/mei/client.h +++ b/drivers/misc/mei/client.h @@ -138,11 +138,11 @@ static inline u8 mei_cl_me_id(const stru * * @cl: host client * - * Return: mtu + * Return: mtu or 0 if client is not connected */ static inline size_t mei_cl_mtu(const struct mei_cl *cl) { - return cl->me_cl->props.max_msg_length; + return cl->me_cl ? cl->me_cl->props.max_msg_length : 0; } /**