From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>,
jikos@kernel.org, benjamin.tissoires@redhat.com,
Even Xu <even.xu@intel.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] HID: intel_ish-hid: Add check for ishtp_dma_tx_map
Date: Tue, 20 Dec 2022 09:08:03 -0800 [thread overview]
Message-ID: <c8e7fdb0e29b975537551ed6331f91b76e426246.camel@linux.intel.com> (raw)
In-Reply-To: <20221122134823.540-1-jiasheng@iscas.ac.cn>
On Tue, 2022-11-22 at 21:48 +0800, Jiasheng Jiang wrote:
> As the kcalloc may return NULL pointer,
> it should be better to check the ishtp_dma_tx_map
> before use in order to avoid NULL pointer dereference.
>
> Fixes: 3703f53b99e4 ("HID: intel_ish-hid: ISH Transport layer")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
+Even Xu, We should do during alloc. Please try to submit a change for
that for later kernel rev as it will require error processing during
hbm dispatch.
> drivers/hid/intel-ish-hid/ishtp/dma-if.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/hid/intel-ish-hid/ishtp/dma-if.c
> b/drivers/hid/intel-ish-hid/ishtp/dma-if.c
> index 40554c8daca0..00046cbfd4ed 100644
> --- a/drivers/hid/intel-ish-hid/ishtp/dma-if.c
> +++ b/drivers/hid/intel-ish-hid/ishtp/dma-if.c
> @@ -104,6 +104,11 @@ void *ishtp_cl_get_dma_send_buf(struct
> ishtp_device *dev,
> int required_slots = (size / DMA_SLOT_SIZE)
> + 1 * (size % DMA_SLOT_SIZE != 0);
>
> + if (!dev->ishtp_dma_tx_map) {
> + dev_err(dev->devc, "Fail to allocate Tx map\n");
> + return NULL;
> + }
> +
> spin_lock_irqsave(&dev->ishtp_dma_tx_lock, flags);
> for (i = 0; i <= (dev->ishtp_dma_num_slots - required_slots);
> i++) {
> free = 1;
> @@ -150,6 +155,11 @@ void ishtp_cl_release_dma_acked_mem(struct
> ishtp_device *dev,
> return;
> }
>
> + if (!dev->ishtp_dma_tx_map) {
> + dev_err(dev->devc, "Fail to allocate Tx map\n");
> + return;
> + }
> +
> i = (msg_addr - dev->ishtp_host_dma_tx_buf) / DMA_SLOT_SIZE;
> spin_lock_irqsave(&dev->ishtp_dma_tx_lock, flags);
> for (j = 0; j < acked_slots; j++) {
next prev parent reply other threads:[~2022-12-20 17:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 13:48 [PATCH] HID: intel_ish-hid: Add check for ishtp_dma_tx_map Jiasheng Jiang
2022-12-20 14:51 ` Jiri Kosina
2022-12-20 17:08 ` srinivas pandruvada [this message]
2022-12-21 8:02 ` Xu, Even
2023-01-02 12:51 ` Jiri Kosina
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=c8e7fdb0e29b975537551ed6331f91b76e426246.camel@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=benjamin.tissoires@redhat.com \
--cc=even.xu@intel.com \
--cc=jiasheng@iscas.ac.cn \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).