> int mlx5_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) > { > - dereg_mr(to_mdev(ibmr->device), to_mmr(ibmr)); > + struct mlx5_ib_mr *mmr = to_mmr(ibmr); > + > + if (ibmr->type == IB_MR_TYPE_INTEGRITY) > + dereg_mr(to_mdev(mmr->pi_mr->ibmr.device), mmr->pi_mr); > + > + dereg_mr(to_mdev(ibmr->device), mmr); Just curious: how could the device for the PI MR be different? In other words, why can't this just be: struct mlx5_ib_mr *mmr = to_mmr(ibmr); if (ibmr->type == IB_MR_TYPE_INTEGRITY) mmr = mmr->pi_mr; dereg_mr(to_mdev(ibmr->device), mmr);