}
 
        buf = get_cpu_var(um_pci_msg_bufs);
-       memcpy(buf, cmd, cmd_size);
+       if (buf)
+               memcpy(buf, cmd, cmd_size);
 
        if (posted) {
                u8 *ncmd = kmalloc(cmd_size + extra_size, GFP_ATOMIC);
        struct um_pci_message_buffer *buf;
        u8 *data;
        unsigned long ret = ULONG_MAX;
+       size_t bytes = sizeof(buf->data);
 
        if (!dev)
                return ULONG_MAX;
        buf = get_cpu_var(um_pci_msg_bufs);
        data = buf->data;
 
-       memset(buf->data, 0xff, sizeof(buf->data));
+       if (buf)
+               memset(data, 0xff, bytes);
 
        switch (size) {
        case 1:
                goto out;
        }
 
-       if (um_pci_send_cmd(dev, &hdr, sizeof(hdr), NULL, 0, data, 8))
+       if (um_pci_send_cmd(dev, &hdr, sizeof(hdr), NULL, 0, data, bytes))
                goto out;
 
        switch (size) {