linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Charles Wang <charles.goodix@gmail.com>,
	Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <bentiss@kernel.org>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v2 next] HID: hid-goodix: Fix type promotion bug in goodix_hid_get_raw_report()
Date: Thu, 29 Aug 2024 12:33:02 -0700	[thread overview]
Message-ID: <ZtDM7ozPG9Rbeamb@google.com> (raw)
In-Reply-To: <a04cfa63-de06-4d09-af80-a567f2db8f12@stanley.mountain>

On Thu, Aug 29, 2024 at 10:30:39PM +0300, Dan Carpenter wrote:
> The issue is GOODIX_HID_PKG_LEN_SIZE is defined as sizeof(u16) which is
> type size_t.  However, goodix_hid_check_ack_status() returns negative
> error codes or potentially a positive but invalid length which is too
> small.  So when we compare "if ((response_data_len <=
> GOODIX_HID_PKG_LEN_SIZE)" then negative error codes are type promoted to
> size_t and counted as a positive large value and treated as valid.
> 
> It would have been easy enough to add some casting to avoid the type
> promotion, however this patch takes a more thourough approach and moves
> the length check into goodix_hid_check_ack_status().  Now the function
> only return negative error codes or zero on success and the length
> pointer is never set to an invalid length.
> 
> Fixes: 75e16c8ce283 ("HID: hid-goodix: Add Goodix HID-over-SPI driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Thanks Dan!

-- 
Dmitry

  reply	other threads:[~2024-08-29 19:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-29 19:30 [PATCH v2 next] HID: hid-goodix: Fix type promotion bug in goodix_hid_get_raw_report() Dan Carpenter
2024-08-29 19:33 ` Dmitry Torokhov [this message]
2024-08-29 19: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=ZtDM7ozPG9Rbeamb@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=charles.goodix@gmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=jikos@kernel.org \
    --cc=kernel-janitors@vger.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).