Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3853636pxb; Tue, 17 Nov 2020 05:26:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1Kcg63Dm9NSlcSXTrMIo6dnBgirtzgPRqQz6ukK9ZLMqAwhvQxoHyI6JyhFoqODz4jwPE X-Received: by 2002:a17:906:2602:: with SMTP id h2mr15294886ejc.358.1605619605222; Tue, 17 Nov 2020 05:26:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605619605; cv=none; d=google.com; s=arc-20160816; b=Ld6VWuP/kkcgm6NHHL56BqrcoxZQcMBNPyDQ396WG68mjLAmUXoa0xEwufR/uZua4b 4OUftqL8ivpnmQIIIqCUm6XtSt8Inzt6Lkxic05rxbMourxs++C6W0HKDz/F+6hGi/5w hQ4YS7ZOujjP9zHjVsZNSztKBbsdo3Ir/nwljCt6Kju8KirtFQ2P+SlqAemhFz+MOKgc lyYf9K2EajFgag0B3/2JCXUp2UD6JGUF5AIpoyIG5X9YL1fUDZm8t7Kl+FLqOXdAF3NJ VDinOB/4JdRHz05JzGh00YkTcrAR0L3mU2pE9O0ZdZpyBlq7AGr0y9X+lzgW9oDVeaBF yAzw== 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=pqW5pBceY+6sYINOdcqCj//Uli1c2n/eOf8two2vFdTLxxlX4RaAC7fFmojhL1+9aR LwhRRhqHG6DiXNk9fk06jRVuBGvd5IN3gDktpTrpxsmpEf+TBfSrJsZsVQ0vNwSBzqMY fAj7CQ1IGbl17A3Oz6C680Ohz7ZCryrWC68HTKVztlkFkKDO7CKrqbJ+6cvPdcPjdckx OnzxeK9kqEfyfS/PQTlQY49ilQvH5gOYauloPYsNxGmj1R526WnOFL2s5GL1uizgtTU+ K14mZSC+eVuJt1Alo4IabfvVvCiFFB1qFaeuztCzoEcLQ9RcQCW/zT8l5T1lM3bxEmL9 2CJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AqhLf5OJ; 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 ho18si13562089ejc.19.2020.11.17.05.26.22; Tue, 17 Nov 2020 05:26:45 -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=AqhLf5OJ; 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 S1731170AbgKQNWf (ORCPT + 99 others); Tue, 17 Nov 2020 08:22:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:56758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731157AbgKQNW2 (ORCPT ); Tue, 17 Nov 2020 08:22:28 -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 11FF62463D; Tue, 17 Nov 2020 13:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619347; bh=+rgwgfGorZpGwIOPV5zY/fKHJ4P2fVNO+fpHvwOEpZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AqhLf5OJyMhF4t+2tWZ4ZGRqSzKdAQxZ9CnaXOjd5yEHk5tJlnfSHIYiQ70QQMAJ8 lP2ruhotyKxgVtbiAJdRZXR8zdmmtveo+3PQYchKqjxnrJuNKVDkecI4X7MouBeySn 7t5Ee48vkZHjhcx5Ll90uEdpy+HrXWZgpRsATC68= 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.19 072/101] mei: protect mei_cl_mtu from null dereference Date: Tue, 17 Nov 2020 14:05:39 +0100 Message-Id: <20201117122116.623487056@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122113.128215851@linuxfoundation.org> References: <20201117122113.128215851@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; } /**