};
        struct {
                struct type6_hdr hdr;
-               struct CPRBX cprbx;
+               union {
+                       struct CPRBX cprbx;
+                       DECLARE_FLEX_ARRAY(u8, userdata);
+               };
        } __packed * msg = ap_msg->msg;
 
        int rcblen = CEIL4(xcrb->request_control_blk_length);
        msg->hdr.fromcardlen2 = xcrb->reply_data_length;
 
        /* prepare CPRB */
-       if (z_copy_from_user(userspace, &msg->cprbx, xcrb->request_control_blk_addr,
+       if (z_copy_from_user(userspace, msg->userdata,
+                            xcrb->request_control_blk_addr,
                             xcrb->request_control_blk_length))
                return -EFAULT;
        if (msg->cprbx.cprb_len + sizeof(msg->hdr.function_code) >
 
        struct {
                struct type6_hdr hdr;
-               struct ep11_cprb cprbx;
-               unsigned char   pld_tag;        /* fixed value 0x30 */
-               unsigned char   pld_lenfmt;     /* payload length format */
+               union {
+                       struct {
+                               struct ep11_cprb cprbx;
+                               unsigned char pld_tag;    /* fixed value 0x30 */
+                               unsigned char pld_lenfmt; /* length format */
+                       } __packed;
+                       DECLARE_FLEX_ARRAY(u8, userdata);
+               };
        } __packed * msg = ap_msg->msg;
 
        struct pld_hdr {
        msg->hdr.fromcardlen1 = xcrb->resp_len;
 
        /* Import CPRB data from the ioctl input parameter */
-       if (z_copy_from_user(userspace, &msg->cprbx.cprb_len,
+       if (z_copy_from_user(userspace, msg->userdata,
                             (char __force __user *)xcrb->req, xcrb->req_len)) {
                return -EFAULT;
        }