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.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 7f097989cde2..c9890e25cd4c 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -45,7 +45,6 @@
45#include <linux/capability.h> 45#include <linux/capability.h>
46#include <linux/module.h> 46#include <linux/module.h>
47#include <linux/types.h> 47#include <linux/types.h>
48#include <linux/smp_lock.h>
49#include <linux/socket.h> 48#include <linux/socket.h>
50#include <linux/sockios.h> 49#include <linux/sockios.h>
51#include <linux/slab.h> 50#include <linux/slab.h>
@@ -2281,6 +2280,16 @@ static int irda_getsockopt(struct socket *sock, int level, int optname,
2281 2280
2282 switch (optname) { 2281 switch (optname) {
2283 case IRLMP_ENUMDEVICES: 2282 case IRLMP_ENUMDEVICES:
2283
2284 /* Offset to first device entry */
2285 offset = sizeof(struct irda_device_list) -
2286 sizeof(struct irda_device_info);
2287
2288 if (len < offset) {
2289 err = -EINVAL;
2290 goto out;
2291 }
2292
2284 /* Ask lmp for the current discovery log */ 2293 /* Ask lmp for the current discovery log */
2285 discoveries = irlmp_get_discoveries(&list.len, self->mask.word, 2294 discoveries = irlmp_get_discoveries(&list.len, self->mask.word,
2286 self->nslots); 2295 self->nslots);
@@ -2291,15 +2300,9 @@ static int irda_getsockopt(struct socket *sock, int level, int optname,
2291 } 2300 }
2292 2301
2293 /* Write total list length back to client */ 2302 /* Write total list length back to client */
2294 if (copy_to_user(optval, &list, 2303 if (copy_to_user(optval, &list, offset))
2295 sizeof(struct irda_device_list) -
2296 sizeof(struct irda_device_info)))
2297 err = -EFAULT; 2304 err = -EFAULT;
2298 2305
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 */ 2306 /* Copy the list itself - watch for overflow */
2304 if (list.len > 2048) { 2307 if (list.len > 2048) {
2305 err = -EINVAL; 2308 err = -EINVAL;