提交 00ee7a37 编写于 作者: O Octavian Purdila 提交者: Lee Jones

mfd: dln2: Add a limit check for invalid echo

The echo field in dln2_transfer_complete comes directly from an USB
transfer and we should not trust it is valid.
Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NOctavian Purdila <octavian.purdila@intel.com>
Signed-off-by: NLee Jones <lee.jones@linaro.org>
上级 93316428
...@@ -195,6 +195,9 @@ static bool dln2_transfer_complete(struct dln2_dev *dln2, struct urb *urb, ...@@ -195,6 +195,9 @@ static bool dln2_transfer_complete(struct dln2_dev *dln2, struct urb *urb,
struct dln2_rx_context *rxc; struct dln2_rx_context *rxc;
bool valid_slot = false; bool valid_slot = false;
if (rx_slot >= DLN2_MAX_RX_SLOTS)
goto out;
rxc = &rxs->slots[rx_slot]; rxc = &rxs->slots[rx_slot];
/* /*
...@@ -210,6 +213,7 @@ static bool dln2_transfer_complete(struct dln2_dev *dln2, struct urb *urb, ...@@ -210,6 +213,7 @@ static bool dln2_transfer_complete(struct dln2_dev *dln2, struct urb *urb,
} }
spin_unlock(&rxs->lock); spin_unlock(&rxs->lock);
out:
if (!valid_slot) if (!valid_slot)
dev_warn(dev, "bad/late response %d/%d\n", handle, rx_slot); dev_warn(dev, "bad/late response %d/%d\n", handle, rx_slot);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册