Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3844193pxb; Tue, 17 Nov 2020 05:13:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJydAwIn6847VrCKqaXy/z2M7DLRyDoXwSvTrdoc2Tsus8V9clXCjrdngImeZV63NtgrlrQT X-Received: by 2002:a17:906:e4f:: with SMTP id q15mr18819199eji.220.1605618798122; Tue, 17 Nov 2020 05:13:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605618798; cv=none; d=google.com; s=arc-20160816; b=aOiDhvXAf0baCMhN8TmmoVPlq/rPSc+BUK8nd2rz1TDKRjBC6w7VKc0CbBxjEzVvkp 21xEVcuoBWTZhOsjyxsGbWGkEKqBxP28j4lwZHu8GOs13pS5x10MjYfz04r8UKZh6+GR eg7csH/pcm4XfqhgfEtQcNsVJSDsDY98dDwgWsBbh5mOWS4pMjXgWue/XMBZzzWMTQC1 NNHzekFZY4QOrzGiiA9TBoY2Zt8dL+0iWpQcVu+qfL8LMKAXnnTi0zxaJW8F1eXTVNyw v5Cq0CpMQmJel86Rd0rw6R6IdABl900fPHYw0E02W59Yn7V7bV1xNkCpuJL7igUMETgh iLiA== 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=odL540twWv7Dx+n8fBOJPptcIJl69GFMyLCWzp0Oq6o=; b=Bt904D+vbApqyZrqntcutA+C/lJ/z9SGx+zt10jnWosWMmjbBSTG5wHWT+dCWCaBSU S6IaWu3nc3y0J7ieAEWZWocr4Peh4Fo9TLje+JXHXd+djoM/A1UTTGwHN+Pz6qDRWEHn ftDjL0133L1IdT052DAjkEIRG/kD0MHUNG2DMGAEdIo8MKvNJlq+ZKgrM+MYuu4OyrEN 3ioaPnkWoJVWbDgQk/SgoCdyR8/3zqXIVZQ9g5SsImfAmZV+BBh63vts5TkffFHJ/BOW 05Nl7rdoCnBknd0XEneGBq3g9dZTHL+lHdOw2Flzr1JO85RJIMfKCWqmVNE43YQK4jC/ CqTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YjbNWrgG; 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 co22si13637057edb.469.2020.11.17.05.12.53; Tue, 17 Nov 2020 05:13:18 -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=YjbNWrgG; 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 S1728651AbgKQNJM (ORCPT + 99 others); Tue, 17 Nov 2020 08:09:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:37558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728498AbgKQNIy (ORCPT ); Tue, 17 Nov 2020 08:08:54 -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 921FB246BC; Tue, 17 Nov 2020 13:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605618534; bh=bDiUE3Eha4KTeAqzc1mssI3d5b8AScDTg3IoKj/Uylo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YjbNWrgGBJK4nEeUVXWI7XPYIdmzjQddCGM+2L2qHw67OiIuY5Tj86daWACW+3SEr oGABcOdKxOGUAFD0bOC9fq4x7g5nftW1PXgjALnbkMlSe8rjF0i++Ft0E+ibX13Ny/ ObUgP9sQufTaFe2wB79T7GUmwA12P/msxoWXcdKA= 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.4 35/64] mei: protect mei_cl_mtu from null dereference Date: Tue, 17 Nov 2020 14:04:58 +0100 Message-Id: <20201117122107.891486298@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122106.144800239@linuxfoundation.org> References: <20201117122106.144800239@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 @@ -156,11 +156,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; } /**