staging/ipack: Fix bug introduced by IPack device matching
authorJens Taprogge <jens.taprogge@taprogge.org>
Fri, 7 Sep 2012 08:29:19 +0000 (10:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Sep 2012 15:27:34 +0000 (08:27 -0700)
~0 can not be casted to u8.  Instead of using the IPACK_ANY_ID for the format
field we introduce a new IPACK_ANY_FORMAT specifically for that field and
defined as 0xff.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jens Taprogge <jens.taprogge@taprogge.org>
Acked-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ipack/ipack.c
include/linux/mod_devicetable.h
scripts/mod/file2alias.c

index b3736c0a1086e589eb54245f0b173226d7a60081..659aadcac04da543ac98fece535a4fe4d99a934d 100644 (file)
@@ -31,7 +31,8 @@ static inline const struct ipack_device_id *
 ipack_match_one_device(const struct ipack_device_id *id,
                       const struct ipack_device *device)
 {
-       if ((id->format == IPACK_ANY_ID || id->format == device->id_format) &&
+       if ((id->format == IPACK_ANY_FORMAT ||
+                               id->format == device->id_format) &&
            (id->vendor == IPACK_ANY_ID || id->vendor == device->id_vendor) &&
            (id->device == IPACK_ANY_ID || id->device == device->id_device))
                return id;
index 999c4c25fbf7e4664dc992adbec14ba468bf1f4f..70c6a359b2f4d125f82b872766a88c58abdf531e 100644 (file)
@@ -600,6 +600,7 @@ struct x86_cpu_id {
 #define X86_MODEL_ANY  0
 #define X86_FEATURE_ANY 0      /* Same as FPU, you can't test for that */
 
+#define IPACK_ANY_FORMAT 0xff
 #define IPACK_ANY_ID (~0)
 struct ipack_device_id {
        __u8  format;                   /* Format version or IPACK_ANY_ID */
index 3c22bda8fdf3a079d69c97abfa1e5eb47a42f4f5..df4fc23dd8360bf40673311511d6a4dac5b100b0 100644 (file)
@@ -973,7 +973,7 @@ static int do_ipack_entry(const char *filename,
        id->vendor = TO_NATIVE(id->vendor);
        id->device = TO_NATIVE(id->device);
        strcpy(alias, "ipack:");
-       ADD(alias, "f", id->format != IPACK_ANY_ID, id->format);
+       ADD(alias, "f", id->format != IPACK_ANY_FORMAT, id->format);
        ADD(alias, "v", id->vendor != IPACK_ANY_ID, id->vendor);
        ADD(alias, "d", id->device != IPACK_ANY_ID, id->device);
        add_wildcard(alias);