Skip to contentSkip to conversation

PATCH: trivial, nsc-ircc dongle_id fix

PATCH [email protected] 1 participant 1 message Oct 11, 2004

lore
Share & tools
lore
#0 lore raw

Hi!
The following patch add checks for parameter dongle_id in module nsc-ircc. In the original version kernel opsed if passed mad dongle_id values, also expliciting forcing dongle_id 0 was not possible.
This patch proposal trivially fix it.
altought this is against 2.6.6 kernel (sorry for that), quickly looking the code of 2.6.8.1 seems that the bug still exist (code is mostly unchanged). Regards,
Andrea Merello

nsc-ircc.c 2004-10-11 17:13:38.000000000 +0200 renamed from nsc-ircc.c.orig 2004-10-11 16:32:16.000000000 +0200 +3 -3
@@ -72,7 +72,7 @@ static char *driver_name = "nsc-ircc";
 
 /* Module parameters */
 static int qos_mtt_bits = 0x07;  /* 1 ms or more */
-static int dongle_id;
+static int dongle_id=-1;
 
 /* Use BIOS settions by default, but user may supply module parameters */
 static unsigned int io[]  = { ~0, ~0, ~0, ~0 };
@@ -349,12 +349,17 @@ static int __init nsc_ircc_open(int i, c
        MESSAGE("IrDA: Registered device %s\n", dev->name);
 
        /* Check if user has supplied the dongle id or not */
-       if (!dongle_id) {
+       if (dongle_id == -1) {
                dongle_id = nsc_ircc_read_dongle_id(self->io.fir_base);
-
                MESSAGE("%s, Found dongle: %s\n", driver_name,
                        dongle_types[dongle_id]);
        } else {
+               if(dongle_id < 0 || dongle_id >= sizeof(dongle_types) / 

sizeof(char*)){

+                       MESSAGE ("%s, Invalid dongle_id: %d\n",driver_name,
+                       dongle_id);
+                       err=-1;
+                       goto out5;
+               }
                MESSAGE("%s, Using dongle: %s\n", driver_name,
                        dongle_types[dongle_id]);
        }
@@ -367,6 +372,8 @@ static int __init nsc_ircc_open(int i, c
                 pmdev->data = self;

        return 0;
+ out5:
+       unregister_netdev(dev);
  out4:
        kfree(self->tx_buff.head);