]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mei: protect mei_cl_mtu from null dereference
authorAlexander Usyskin <alexander.usyskin@intel.com>
Thu, 29 Oct 2020 09:54:42 +0000 (11:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Nov 2020 17:27:58 +0000 (18:27 +0100)
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: <stable@vger.kernel.org>
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20201029095444.957924-2-tomas.winkler@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/client.h

index 5371df4d8af3cc1b2ee25d3566383bdf393045da..be4fe2ea0afdd64694ec922487152b5a76adb0f6 100644 (file)
@@ -138,11 +138,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;
 }
 
 /**