diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c index 83322cd7673a..77c63c3f820f 100644 --- a/drivers/virt/coco/tdx-guest/tdx-guest.c +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c @@ -170,8 +170,6 @@ static void tdx_mr_deinit(const struct attribute_group *mr_grp) #define GET_QUOTE_SUCCESS 0 #define GET_QUOTE_IN_FLIGHT 0xffffffffffffffff -#define TDX_QUOTE_MAX_LEN (GET_QUOTE_BUF_SIZE - sizeof(struct tdx_quote_buf)) - /* struct tdx_quote_buf: Format of Quote request buffer. * @version: Quote format version, filled by TD. * @status: Status code of Quote request, filled by VMM. @@ -313,7 +311,7 @@ static int tdx_report_new_locked(struct tsm_report *report) out_len = READ_ONCE(quote_buf->out_len); - if (out_len > TDX_QUOTE_MAX_LEN) + if (struct_size(quote_buf, data, out_len) > GET_QUOTE_BUF_SIZE) return -EFBIG; buf = kvmemdup(quote_buf->data, out_len, GFP_KERNEL);