From patchwork Thu Oct 29 09:54:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Winkler, Tomas" X-Patchwork-Id: 317451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26E36C2D0A3 for ; Thu, 29 Oct 2020 09:55:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA2F32076E for ; Thu, 29 Oct 2020 09:55:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726335AbgJ2JzY (ORCPT ); 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 Precedence: bulk List-ID: X-Mailing-List: stable@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; } /**