From: Greg KH <gregkh@linuxfoundation.org>
To: clingfei <clf700383@gmail.com>
Cc: elder@kernel.org, keescook@chromium.org, johan@kernel.org,
vireshk@kernel.org, greybus-dev@lists.linaro.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] greybus: Avoid fake flexible array for response data
Date: Tue, 27 May 2025 07:15:19 +0200 [thread overview]
Message-ID: <2025052700-ungodly-vitality-d86d@gregkh> (raw)
In-Reply-To: <20250527050635.946553-1-clf700383@gmail.com>
On Tue, May 27, 2025 at 01:06:35PM +0800, clingfei wrote:
> We want to get rid of zero size arrays and use flexible arrays instead.
> However, in this case the struct is just one flexible array of u8 which
> adds no value. Just use a pointer instead.
Not true at all, sorry, it does "add value". Please read the greybus
specification if you have questions about this.
>
> v1: https://lore.kernel.org/all/202505262032.507AD8E0DC@keescook/
Please read our documentation for how to properly version kernel patches
>
> Signed-off-by: clingfei <clf700383@gmail.com>
Also, we need a "full"name, not an email alias.
> ---
> drivers/staging/greybus/i2c.c | 12 ++++--------
> include/linux/greybus/greybus_protocols.h | 3 ---
> 2 files changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/greybus/i2c.c b/drivers/staging/greybus/i2c.c
> index 14f1ff6d448c..b248d6717b71 100644
> --- a/drivers/staging/greybus/i2c.c
> +++ b/drivers/staging/greybus/i2c.c
> @@ -144,15 +144,14 @@ gb_i2c_operation_create(struct gb_connection *connection,
> }
>
> static void gb_i2c_decode_response(struct i2c_msg *msgs, u32 msg_count,
> - struct gb_i2c_transfer_response *response)
> + u8 *data)
> {
> struct i2c_msg *msg = msgs;
> - u8 *data;
> u32 i;
>
> - if (!response)
> + if (!data)
> return;
> - data = response->data;
> +
> for (i = 0; i < msg_count; i++) {
> if (msg->flags & I2C_M_RD) {
> memcpy(msg->buf, data, msg->len);
> @@ -188,10 +187,7 @@ static int gb_i2c_transfer_operation(struct gb_i2c_device *gb_i2c_dev,
>
> ret = gb_operation_request_send_sync(operation);
> if (!ret) {
> - struct gb_i2c_transfer_response *response;
> -
> - response = operation->response->payload;
> - gb_i2c_decode_response(msgs, msg_count, response);
> + gb_i2c_decode_response(msgs, msg_count, operation->response->payload);
> ret = msg_count;
> } else if (!gb_i2c_expected_transfer_error(ret)) {
> dev_err(dev, "transfer operation failed (%d)\n", ret);
> diff --git a/include/linux/greybus/greybus_protocols.h b/include/linux/greybus/greybus_protocols.h
> index 820134b0105c..6a35c78b967b 100644
> --- a/include/linux/greybus/greybus_protocols.h
> +++ b/include/linux/greybus/greybus_protocols.h
> @@ -678,9 +678,6 @@ struct gb_i2c_transfer_request {
> __le16 op_count;
> struct gb_i2c_transfer_op ops[]; /* op_count of these */
> } __packed;
> -struct gb_i2c_transfer_response {
> - __u8 data[0]; /* inbound data */
> -} __packed;
As I said before, you can't just delete structures that are exported to
userspace without breaking things. Why is this change acceptable to do
that?
And how was any of this tested?
greg k-h
next prev parent reply other threads:[~2025-05-27 5:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-27 5:06 [PATCH v2] greybus: Avoid fake flexible array for response data clingfei
2025-05-27 5:15 ` Greg KH [this message]
2025-05-27 5:50 ` clingfei
2025-05-27 6:09 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2024-03-04 21:19 Kees Cook
2024-03-04 22:45 ` Alex Elder
2024-03-04 23:10 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2025052700-ungodly-vitality-d86d@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=clf700383@gmail.com \
--cc=elder@kernel.org \
--cc=greybus-dev@lists.linaro.org \
--cc=johan@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=vireshk@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox