linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
To: Tanu Malhotra <tanu.malhotra@intel.com>, jikos@kernel.org
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	even.xu@intel.com, Shaunak Saha <shaunak.saha@intel.com>
Subject: Re: [PATCH] HID: intel-ish-hid: Fix kernel panic during warm reset
Date: Mon, 27 Mar 2023 05:10:14 -0700	[thread overview]
Message-ID: <c6b89edad5f74bf5ca82401a3d9cc5b4198baac8.camel@linux.intel.com> (raw)
In-Reply-To: <20230327032310.2416272-1-tanu.malhotra@intel.com>

On Sun, 2023-03-26 at 20:23 -0700, Tanu Malhotra wrote:

some minor nits below.

> During warm reset device->fw_client is set to NULL. If a bus driver
> is
> registered after this NULL setting and before new firmware clients
> are
> enumerated by ISHTP, kernel panic will result in the function
> ishtp_cl_bus_match(). This is because of reference to
> device->fw_client->props.protocol_name.
> 
> ISH firmware after getting successfully loaded, sends a warm reset
> notification to remove all clients from the bus and sets
> device->fw_client to NULL. Until kernel v5.15, all enabled ISHTP
> kernel
> module drivers were loaded after any of the first ISHTP device was
> registered, regardless of whether it was a matched or an unmatched
> device. This resulted in all drivers getting registered much before
> the
> warm reset notification from ISH. Starting kernel v5.16, this issue
> got
> exposed after the change was introduced to load only bus drivers for
> the
> respective matching devices.
One paragraph break will be better.

>  In this scenario, cros_ec_ishtp device and
> cros_ec_ishtp driver are registered after the warm reset
> device_fw_client NULL setting. cros_ec_ishtp driver_register()
> triggers
> the callback to ishtp_cl_bus_match() to match driver to the device
> and
> causes kernel panic in guid_equal() when dereferencing fw_client NULL
> pointer to get protocol_name.
> 
> Fixes: f155dfeaa4ee ("platform/x86: isthp_eclite: only load for
> matching devices")
> Fixes: facfe0a4fdce ("platform/chrome: chros_ec_ishtp: only load for
> matching devices")
> Fixes: 0d0cccc0fd83 ("HID: intel-ish-hid: hid-client: only load for
> matching devices")
> Fixes: 44e2a58cb880 ("HID: intel-ish-hid: fw-loader: only load for
> matching devices")
> 
No need of blank line.

> Signed-off-by: Tanu Malhotra <tanu.malhotra@intel.com>
> Tested-by: Shaunak Saha <shaunak.saha@intel.com>
You can also add 
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


Also add
Cc: <stable@vger.kernel.org> # 5.16+

> ---
When you submit "PATCH v2", Add change log here. (That is below "---").
Something like this:
v2
- Updated commit description
- Added CC to stable

>  drivers/hid/intel-ish-hid/ishtp/bus.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c
> b/drivers/hid/intel-ish-hid/ishtp/bus.c
> index 81385ab37fa9..4f540906268f 100644
> --- a/drivers/hid/intel-ish-hid/ishtp/bus.c
> +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c
> @@ -241,8 +241,8 @@ static int ishtp_cl_bus_match(struct device *dev,
> struct device_driver *drv)
>         struct ishtp_cl_device *device = to_ishtp_cl_device(dev);
>         struct ishtp_cl_driver *driver = to_ishtp_cl_driver(drv);
>  
> -       return guid_equal(&driver->id[0].guid,
> -                         &device->fw_client->props.protocol_name);
> +       return(device->fw_client ? guid_equal(&driver->id[0].guid,
> +                                 &device->fw_client-
> >props.protocol_name) : 0);
Align the second line to char "d" after "(".

Thanks,
Srinivas

>  }
>  
>  /**


      reply	other threads:[~2023-03-27 12:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27  3:23 [PATCH] HID: intel-ish-hid: Fix kernel panic during warm reset Tanu Malhotra
2023-03-27 12:10 ` srinivas pandruvada [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=c6b89edad5f74bf5ca82401a3d9cc5b4198baac8.camel@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=even.xu@intel.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shaunak.saha@intel.com \
    --cc=tanu.malhotra@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).