]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cifs: fix the out of range assignment to bit fields in parse_server_interfaces
authorHyunchul Lee <hyc.lee@gmail.com>
Mon, 12 Jul 2021 10:34:02 +0000 (19:34 +0900)
committerSteve French <stfrench@microsoft.com>
Wed, 14 Jul 2021 15:06:33 +0000 (10:06 -0500)
Because the out of range assignment to bit fields
are compiler-dependant, the fields could have wrong
value.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/smb2ops.c

index e4c8f603dd58891ed1b8125a07cbfac0a05086bc..232d528df230d3725dbfcfd0c60f929e06031589 100644 (file)
@@ -557,8 +557,8 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
        p = buf;
        while (bytes_left >= sizeof(*p)) {
                info->speed = le64_to_cpu(p->LinkSpeed);
-               info->rdma_capable = le32_to_cpu(p->Capability & RDMA_CAPABLE);
-               info->rss_capable = le32_to_cpu(p->Capability & RSS_CAPABLE);
+               info->rdma_capable = le32_to_cpu(p->Capability & RDMA_CAPABLE) ? 1 : 0;
+               info->rss_capable = le32_to_cpu(p->Capability & RSS_CAPABLE) ? 1 : 0;
 
                cifs_dbg(FYI, "%s: adding iface %zu\n", __func__, *iface_count);
                cifs_dbg(FYI, "%s: speed %zu bps\n", __func__, info->speed);