Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mei: amthif: discard not read messages

When a message is received and amthif client is not in reading state
the message is ignored and left dangling in the queue. This may happen
after one of the amthif host connections is closed w/o completing the
reading. Another client will pick up a wrong message on next read
attempt which will lead to link reset.
To prevent this the driver has to properly discard the message when
amthif client is not in reading state.

Cc: <stable@vger.kernel.org> #4.2+
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexander Usyskin and committed by
Greg Kroah-Hartman
9d04ee11 6a8d648c

+5 -2
+3 -1
drivers/misc/mei/amthif.c
··· 380 380 381 381 dev = cl->dev; 382 382 383 - if (dev->iamthif_state != MEI_IAMTHIF_READING) 383 + if (dev->iamthif_state != MEI_IAMTHIF_READING) { 384 + mei_irq_discard_msg(dev, mei_hdr); 384 385 return 0; 386 + } 385 387 386 388 ret = mei_cl_irq_read_msg(cl, mei_hdr, cmpl_list); 387 389 if (ret)
-1
drivers/misc/mei/interrupt.c
··· 76 76 * @dev: mei device 77 77 * @hdr: message header 78 78 */ 79 - static inline 80 79 void mei_irq_discard_msg(struct mei_device *dev, struct mei_msg_hdr *hdr) 81 80 { 82 81 /*
+2
drivers/misc/mei/mei_dev.h
··· 702 702 703 703 bool mei_write_is_idle(struct mei_device *dev); 704 704 705 + void mei_irq_discard_msg(struct mei_device *dev, struct mei_msg_hdr *hdr); 706 + 705 707 #if IS_ENABLED(CONFIG_DEBUG_FS) 706 708 int mei_dbgfs_register(struct mei_device *dev, const char *name); 707 709 void mei_dbgfs_deregister(struct mei_device *dev);