Commit e15465e1 authored by Dan Carpenter's avatar Dan Carpenter Committed by David S. Miller
Browse files

irda: small read past the end of array in debug code

The "reason" can come from skb->data[] and it hasn't been capped so it
can be from 0-255 instead of just 0-6.  For example in irlmp_state_dtr()
the code does:

	reason = skb->data[3];
	irlmp_disconnect_indication(self, reason, skb);

Also LMREASON has a couple other values which don't have entries in the
irlmp_reasons[] array.  And 0xff is a valid reason as well which means

So far as I can see we don't actually care about "reason" except for in
the debug code.
Signed-off-by: default avatarDan Carpenter <>
Signed-off-by: default avatarDavid S. Miller <>
parent fd7fc253
......@@ -256,7 +256,8 @@ static inline __u32 irlmp_get_daddr(const struct lsap_cb *self)
return (self && self->lap) ? self->lap->daddr : 0;
extern const char *irlmp_reasons[];
const char *irlmp_reason_str(LM_REASON reason);
extern int sysctl_discovery_timeout;
extern int sysctl_discovery_slots;
extern int sysctl_discovery;
......@@ -303,7 +303,8 @@ static void iriap_disconnect_indication(void *instance, void *sap,
struct iriap_cb *self;
IRDA_DEBUG(4, "%s(), reason=%s\n", __func__, irlmp_reasons[reason]);
IRDA_DEBUG(4, "%s(), reason=%s [%d]\n", __func__,
irlmp_reason_str(reason), reason);
self = instance;
......@@ -66,8 +66,15 @@ const char *irlmp_reasons[] = {
const char *irlmp_reason_str(LM_REASON reason)
reason = min_t(size_t, reason, ARRAY_SIZE(irlmp_reasons) - 1);
return irlmp_reasons[reason];
* Function irlmp_init (void)
......@@ -747,7 +754,8 @@ void irlmp_disconnect_indication(struct lsap_cb *self, LM_REASON reason,
struct lsap_cb *lsap;
IRDA_DEBUG(1, "%s(), reason=%s\n", __func__, irlmp_reasons[reason]);
IRDA_DEBUG(1, "%s(), reason=%s [%d]\n", __func__,
irlmp_reason_str(reason), reason);
IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == LMP_LSAP_MAGIC, return;);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment