Skip to content

Commit bcbc0b2

Browse files
ausyskingregkh
authored andcommitted
mei: protect mei_cl_mtu from null dereference
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>
1 parent 3cea11c commit bcbc0b2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/misc/mei/client.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ static inline u8 mei_cl_me_id(const struct mei_cl *cl)
182182
*
183183
* @cl: host client
184184
*
185-
* Return: mtu
185+
* Return: mtu or 0 if client is not connected
186186
*/
187187
static inline size_t mei_cl_mtu(const struct mei_cl *cl)
188188
{
189-
return cl->me_cl->props.max_msg_length;
189+
return cl->me_cl ? cl->me_cl->props.max_msg_length : 0;
190190
}
191191

192192
/**

0 commit comments

Comments
 (0)