Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp303009pxx; Thu, 29 Oct 2020 03:05:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlxA9t6cXGjZ1xHQh174rBIvYrvN1d+vFkKfcBFXxRoULa4moXp8x3L7i5BJO2napc/RE/ X-Received: by 2002:a17:906:4c41:: with SMTP id d1mr2682465ejw.485.1603965924673; Thu, 29 Oct 2020 03:05:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603965924; cv=none; d=google.com; s=arc-20160816; b=A69PsNnRg1s5/kn9pL0CIMsmwurmdu+LUMyZOY1cFyEccPiy2NIx/9+cuIoWAKb6Gl RwPdMKzDtcx68PWwtFvjIV28a5/oe1f3QH7QAI4WtpOJAwSrdjsXEErU/mrn71FJhYGU j9rt8plDA6ZdwDpPqFwxgNvJymIZ+E8Qy+G8hwiaJPYOoPhCkbwYBhgpIL/lTPzBkbSL UJGXEOnyNr3awBBwNga7G8F0i1+ejpjpbqxVJZYKMN26AcHjLW55pjpJra7Txc5++Cyg FST0b+FRq5O+oTQkCg2Q0evzoP/4Nc8mu3fPguB77bJuG3s3hQSoi20oM4Ni2oUmUCcR imZw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=xboivpXwV2lzBDdHSyifnP73TBMg07ENeVd+98OANPk=; b=RqeAsut3NTbEjJdsu2dOgoAHu3deECxX7N6RPhQQzTf7D0nsf25IaEk4G5ZHtRNrzJ LDVI2XtAUxjOciLFo0Cr+xrA3cwTR/jhjufHKrgn9uO0LvzvTWoS2m4NAUtYEzDOfqwq ynfguJTzDnv6wWjI/hgpk82IrDqFYp2SM/X8zhUfLad365fg8E231ihfbcjDuiBNioFd GOtJKfUTz5ry7W16F3XuX2NUOOHjeIJORWPOQxX1TUeAotjaexhCClkyxlNKRRZVz6Fo JwL6u1BH6nE9CZE+ihffbyiALQzSUpA9eQC5y6YmFVcCNl+fSBa+oQ8ZzIj6IG4jYhvj Skfg== ARC-Authentication-Results: i=1; mx.google.com; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t17si1399448ejf.597.2020.10.29.03.05.01; Thu, 29 Oct 2020 03:05:24 -0700 (PDT) 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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726441AbgJ2JzY (ORCPT + 99 others); Thu, 29 Oct 2020 05:55:24 -0400 Received: from mga04.intel.com ([192.55.52.120]:30816 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726407AbgJ2JzY (ORCPT ); Thu, 29 Oct 2020 05:55:24 -0400 IronPort-SDR: opjK48+MHug0BVSm4KQe+3nMAQLtuyvTLdY5rtxb0kbPBYNdYkgJXepAAhbmmo/W+fWu/nVXgy qZwXXPWUkLSg== X-IronPort-AV: E=McAfee;i="6000,8403,9788"; a="165821751" X-IronPort-AV: E=Sophos;i="5.77,429,1596524400"; d="scan'208";a="165821751" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2020 02:55:23 -0700 IronPort-SDR: bnMnt2PfQkYicfAQtV4coNgrJcVSHI/r0B+ZeI+DPx6wlVJx0zul6l63qMVY+3Wi9HcaxR18Nz 7eaN3xCtToeA== X-IronPort-AV: E=Sophos;i="5.77,429,1596524400"; d="scan'208";a="536607337" Received: from twinkler-lnx.jer.intel.com ([10.12.91.138]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2020 02:55:19 -0700 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Tomas Winkler Subject: [char-misc-next 1/3] mei: protect mei_cl_mtu from null dereference Date: Thu, 29 Oct 2020 11:54:42 +0200 Message-Id: <20201029095444.957924-2-tomas.winkler@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201029095444.957924-1-tomas.winkler@intel.com> References: <20201029095444.957924-1-tomas.winkler@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Usyskin 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 --- drivers/misc/mei/client.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h index 64143d4ec758..9e08a9843bba 100644 --- a/drivers/misc/mei/client.h +++ b/drivers/misc/mei/client.h @@ -182,11 +182,11 @@ static inline u8 mei_cl_me_id(const struct mei_cl *cl) * * @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; } /** -- 2.25.4