hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/infiniband/core/user_mad.c
....@@ -131,6 +131,11 @@
131131 struct ib_user_mad mad;
132132 };
133133
134
+struct ib_rmpp_mad_hdr {
135
+ struct ib_mad_hdr mad_hdr;
136
+ struct ib_rmpp_hdr rmpp_hdr;
137
+} __packed;
138
+
134139 #define CREATE_TRACE_POINTS
135140 #include <trace/events/ib_umad.h>
136141
....@@ -494,11 +499,11 @@
494499 size_t count, loff_t *pos)
495500 {
496501 struct ib_umad_file *file = filp->private_data;
502
+ struct ib_rmpp_mad_hdr *rmpp_mad_hdr;
497503 struct ib_umad_packet *packet;
498504 struct ib_mad_agent *agent;
499505 struct rdma_ah_attr ah_attr;
500506 struct ib_ah *ah;
501
- struct ib_rmpp_mad *rmpp_mad;
502507 __be64 *tid;
503508 int ret, data_len, hdr_len, copy_offset, rmpp_active;
504509 u8 base_version;
....@@ -506,7 +511,7 @@
506511 if (count < hdr_size(file) + IB_MGMT_RMPP_HDR)
507512 return -EINVAL;
508513
509
- packet = kzalloc(sizeof *packet + IB_MGMT_RMPP_HDR, GFP_KERNEL);
514
+ packet = kzalloc(sizeof(*packet) + IB_MGMT_RMPP_HDR, GFP_KERNEL);
510515 if (!packet)
511516 return -ENOMEM;
512517
....@@ -560,13 +565,13 @@
560565 goto err_up;
561566 }
562567
563
- rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data;
564
- hdr_len = ib_get_mad_data_offset(rmpp_mad->mad_hdr.mgmt_class);
568
+ rmpp_mad_hdr = (struct ib_rmpp_mad_hdr *)packet->mad.data;
569
+ hdr_len = ib_get_mad_data_offset(rmpp_mad_hdr->mad_hdr.mgmt_class);
565570
566
- if (ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)
571
+ if (ib_is_mad_class_rmpp(rmpp_mad_hdr->mad_hdr.mgmt_class)
567572 && ib_mad_kernel_rmpp_agent(agent)) {
568573 copy_offset = IB_MGMT_RMPP_HDR;
569
- rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
574
+ rmpp_active = ib_get_rmpp_flags(&rmpp_mad_hdr->rmpp_hdr) &
570575 IB_MGMT_RMPP_FLAG_ACTIVE;
571576 } else {
572577 copy_offset = IB_MGMT_MAD_HDR;
....@@ -615,12 +620,12 @@
615620 tid = &((struct ib_mad_hdr *) packet->msg->mad)->tid;
616621 *tid = cpu_to_be64(((u64) agent->hi_tid) << 32 |
617622 (be64_to_cpup(tid) & 0xffffffff));
618
- rmpp_mad->mad_hdr.tid = *tid;
623
+ rmpp_mad_hdr->mad_hdr.tid = *tid;
619624 }
620625
621626 if (!ib_mad_kernel_rmpp_agent(agent)
622
- && ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)
623
- && (ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE)) {
627
+ && ib_is_mad_class_rmpp(rmpp_mad_hdr->mad_hdr.mgmt_class)
628
+ && (ib_get_rmpp_flags(&rmpp_mad_hdr->rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE)) {
624629 spin_lock_irq(&file->send_lock);
625630 list_add_tail(&packet->list, &file->send_list);
626631 spin_unlock_irq(&file->send_lock);