From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: "Jett ✈ Rink" <jettrink@google.com>, egranata@chromium.org
Cc: Guenter Roeck <groeck@google.com>,
Benson Leung <bleung@chromium.org>,
gwendal@chromium.org, amstan@chromium.org,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] mfd: cros_ec: check for NULL transfer function
Date: Mon, 8 Apr 2019 17:50:27 +0200 [thread overview]
Message-ID: <ffc12c5b-2481-ac02-5093-2f14d362ff26@collabora.com> (raw)
In-Reply-To: <CAK+PMK7cGVy-o_GX_p4asEMSsB9KoNK+x5WdNo2b+pXUFzJZGw@mail.gmail.com>
Hi Enrico,
Many thanks to send this upstream.
On 4/4/19 18:00, Jett ✈ Rink wrote:
> Reviewed-by: Jett Rink <jettrink@chromium.org>
>
> On Wed, Apr 3, 2019 at 4:40 PM <egranata@chromium.org> wrote:
>>
>> From: Enrico Granata <egranata@chromium.org>
>>
>> As new transfer mechanisms are added to the EC codebase, they may
>> not support v2 of the EC protocol.
>>
>> If the v3 initial handshake transfer fails, the kernel will try
>> and call cmd_xfer as a fallback. If v2 is not supported, cmd_xfer
>> will be NULL, and the code will end up causing a kernel panic.
>>
>> Add a check for NULL before calling the transfer function, along
>> with a helpful comment explaining how one might end up in this
>> situation.
>>
>> Signed-off-by: Enrico Granata <egranata@chromium.org>
>> ---
>> drivers/platform/chrome/cros_ec_proto.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
>> index 97a068dff192d..55691656a3c27 100644
>> --- a/drivers/platform/chrome/cros_ec_proto.c
>> +++ b/drivers/platform/chrome/cros_ec_proto.c
>> @@ -56,6 +56,16 @@ static int send_command(struct cros_ec_device *ec_dev,
>> else
>> xfer_fxn = ec_dev->cmd_xfer;
>>
>> + if (xfer_fxn == NULL) {
>> + /* This error can happen if a communication error happened and
Like Guenter I personally don't like the networking-style multi-line comments.
We try to use the default kernel-style so if you don't mind I'll change this.
>> + * the EC is trying to use protocol v2, on an underlying
>> + * communication mechanism that does not support v2.
>> + */
>> + dev_err_once(ec_dev->dev,
>> + "missing EC transfer API, cannot send command\n");
>> + return -EIO;
>> + }
>> +
>> ret = (*xfer_fxn)(ec_dev, msg);
>> if (msg->result == EC_RES_IN_PROGRESS) {
>> int i;
>> --
>> 2.21.0.392.gf8f6787159e-goog
>>
I'll add the patch to the for-next branch in chrome-platform repository for
auto-builders to play with. If all goes well I'll queue the patch for
chrome-platform-5.2.
Thanks,
Enric
prev parent reply other threads:[~2019-04-08 15:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-03 18:30 [PATCH] " egranata
2019-04-03 18:51 ` Guenter Roeck
2019-04-03 19:40 ` Enrico Granata
[not found] ` <CAPR809vTZSFtNp61WQsOFRkFacO_8XEdicqFq9uYMkUMdjEsqg@mail.gmail.com>
2019-04-03 19:53 ` Guenter Roeck
2019-04-03 19:54 ` Enrico Granata
2019-04-03 22:40 ` [PATCH v2] " egranata
2019-04-04 16:00 ` Jett ✈ Rink
2019-04-08 15:50 ` Enric Balletbo i Serra [this message]
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=ffc12c5b-2481-ac02-5093-2f14d362ff26@collabora.com \
--to=enric.balletbo@collabora.com \
--cc=amstan@chromium.org \
--cc=bleung@chromium.org \
--cc=egranata@chromium.org \
--cc=groeck@google.com \
--cc=gwendal@chromium.org \
--cc=jettrink@google.com \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®