X-Git-Url: http://git.etherboot.org/mirror/winof/.git/blobdiff_plain/2af6c6d5376907da8bd3efdd7dc0a97c08d1f1d3..26985ed39da7b0f32984c36620800649f50fdee5:/hw/mthca/kernel/mt_device.c diff --git a/hw/mthca/kernel/mt_device.c b/hw/mthca/kernel/mt_device.c index 52745695..883c9868 100644 --- a/hw/mthca/kernel/mt_device.c +++ b/hw/mthca/kernel/mt_device.c @@ -140,16 +140,18 @@ static int alloc_name(char *name) continue; if (i < 0 || i >= PAGE_SIZE * 8) continue; - snprintf(buf, sizeof(buf)-1, name, i); - buf[sizeof(buf)-1] = '\0'; + if (RtlStringCbPrintfA(buf, sizeof buf, name, i)) + return -EINVAL; + if (!strncmp(buf, device->name, IB_DEVICE_NAME_MAX)) set_bit(i, inuse); } i = find_first_zero_bit((const unsigned long *)inuse, PAGE_SIZE * 8); free_page(inuse); - snprintf(buf, sizeof(buf)-1, name, i); - buf[sizeof(buf)-1] = '\0'; + if (RtlStringCbPrintfA(buf, sizeof buf, name, i)) + return -EINVAL; + if (__ib_device_get_by_name(buf)) return -ENFILE;