kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alex Deucher <alexander.deucher@amd.com>,
	Luben Tuikov <luben.tuikov@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>,
	"Pan, Xinhui" <Xinhui.Pan@amd.com>,
	"David Airlie" <airlied@linux.ie>,
	"Daniel Vetter" <daniel@ffwll.ch>, "Roman Li" <roman.li@amd.com>,
	"Nicholas Kazlauskas" <Nicholas.Kazlauskas@amd.com>,
	"Bindu Ramamurthy" <bindu.r@amd.com>,
	"Andrey Grodzovsky" <andrey.grodzovsky@amd.com>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	kernel-janitors@vger.kernel.org
Subject: [PATCH 2/4] drm/amdgpu: Fix signedness bug in __amdgpu_eeprom_xfer()
Date: Sat, 3 Jul 2021 12:44:57 +0300	[thread overview]
Message-ID: <YOAxmdgHju990Wbd@mwanda> (raw)
In-Reply-To: <YOAsdyWeZAHF0oll@mwanda>

The i2c_transfer() function returns negatives or else the number of
messages transferred.  This code does not work because ARRAY_SIZE()
is type size_t and so that means negative values of "r" are type
promoted to high positive values which are greater than the ARRAY_SIZE().

Fix this by changing the < to != which works regardless of type
promotion.

Fixes: 6cda0af81a50 ("drm/amdgpu: Fixes to the AMDGPU EEPROM driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
index 4c3c65a5acae..4d9eb0137f8c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c
@@ -147,7 +147,7 @@ static int __amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,
 		/* This constitutes a START-STOP transaction.
 		 */
 		r = i2c_transfer(i2c_adap, msgs, ARRAY_SIZE(msgs));
-		if (r < ARRAY_SIZE(msgs))
+		if (r != ARRAY_SIZE(msgs))
 			break;
 
 		if (!read) {
-- 
2.30.2


  reply	other threads:[~2021-07-03  9:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-03  9:44 [PATCH 1/4] drm/amdgpu: fix a signedness bug in __verify_ras_table_checksum() Dan Carpenter
2021-07-03  9:44 ` Dan Carpenter [this message]
2021-07-03  9:45 ` [PATCH 3/4] drm/amdgpu: unlock on error in amdgpu_ras_debugfs_table_read() Dan Carpenter
2021-07-03  9:46 ` [PATCH 4/4] drm/amdgpu: return -EFAULT if copy_to_user() fails Dan Carpenter
2021-07-04 15:18 ` [PATCH 1/4] drm/amdgpu: fix a signedness bug in __verify_ras_table_checksum() Luben Tuikov
2021-07-06  0:52   ` Luben Tuikov

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=YOAxmdgHju990Wbd@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=Nicholas.Kazlauskas@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=andrey.grodzovsky@amd.com \
    --cc=bindu.r@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=luben.tuikov@amd.com \
    --cc=roman.li@amd.com \
    --subject='Re: [PATCH 2/4] drm/amdgpu: Fix signedness bug in __amdgpu_eeprom_xfer()' \
    /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

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).