aboutsummaryrefslogtreecommitdiffstats
path: root/net/irda/af_irda.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/irda/af_irda.c')
-rw-r--r--net/irda/af_irda.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 7f097989cde2..5007541b6478 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -2281,6 +2281,16 @@ static int irda_getsockopt(struct socket *sock, int level, int optname,
2281 2281
2282 switch (optname) { 2282 switch (optname) {
2283 case IRLMP_ENUMDEVICES: 2283 case IRLMP_ENUMDEVICES:
2284
2285 /* Offset to first device entry */
2286 offset = sizeof(struct irda_device_list) -
2287 sizeof(struct irda_device_info);
2288
2289 if (len < offset) {
2290 err = -EINVAL;
2291 goto out;
2292 }
2293
2284 /* Ask lmp for the current discovery log */ 2294 /* Ask lmp for the current discovery log */
2285 discoveries = irlmp_get_discoveries(&list.len, self->mask.word, 2295 discoveries = irlmp_get_discoveries(&list.len, self->mask.word,
2286 self->nslots); 2296 self->nslots);
@@ -2291,15 +2301,9 @@ static int irda_getsockopt(struct socket *sock, int level, int optname,
2291 } 2301 }
2292 2302
2293 /* Write total list length back to client */ 2303 /* Write total list length back to client */
2294 if (copy_to_user(optval, &list, 2304 if (copy_to_user(optval, &list, offset))
2295 sizeof(struct irda_device_list) -
2296 sizeof(struct irda_device_info)))
2297 err = -EFAULT; 2305 err = -EFAULT;
2298 2306
2299 /* Offset to first device entry */
2300 offset = sizeof(struct irda_device_list) -
2301 sizeof(struct irda_device_info);
2302
2303 /* Copy the list itself - watch for overflow */ 2307 /* Copy the list itself - watch for overflow */
2304 if (list.len > 2048) { 2308 if (list.len > 2048) {
2305 err = -EINVAL; 2309 err = -EINVAL;