mirror of https://gitee.com/openkylin/linux.git
greybus: core: add lower-limit for host-device buffers
Make sure we never end up with a host device with maximum buffer size smaller than the shortest Greybus message. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
c38cf10bbe
commit
8e929a8230
|
@ -188,6 +188,11 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (buffer_size_max < GB_OPERATION_MESSAGE_SIZE_MIN) {
|
||||
dev_err(parent, "greybus host-device buffers too small\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure to never allocate messages larger than what the Greybus
|
||||
* protocol supports.
|
||||
|
|
|
@ -69,6 +69,7 @@ struct gb_operation_msg_hdr {
|
|||
__u8 pad[2]; /* must be zero (ignore when read) */
|
||||
} __aligned(sizeof(u64));
|
||||
|
||||
#define GB_OPERATION_MESSAGE_SIZE_MIN sizeof(struct gb_operation_msg_hdr)
|
||||
#define GB_OPERATION_MESSAGE_SIZE_MAX U16_MAX
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue