mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oded Gabbay <oded.gabbay@gmail.com>
To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org
Cc: rppt@linux.ibm.com
Subject: [PATCH] habanalabs: use u64 when comparing variables' sum to u32_max
Date: Sun, 24 Feb 2019 11:55:26 +0200	[thread overview]
Message-ID: <20190224095526.29183-1-oded.gabbay@gmail.com> (raw)

This patch fixes two smatch warnings about two if statements that are
always true because of the types of the variables used - u32 when
comparing the sum to u32_max.

The patch changes the types to be u64 so the accumalted sum can be checked
if it is larger than u32_max

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
---
 drivers/misc/habanalabs/goya/goya.c  | 6 ++++--
 drivers/misc/habanalabs/goya/goyaP.h | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c
index e6f0d49ab71a..fc53cdb38f23 100644
--- a/drivers/misc/habanalabs/goya/goya.c
+++ b/drivers/misc/habanalabs/goya/goya.c
@@ -3474,7 +3474,8 @@ u32 goya_get_dma_desc_list_size(struct hl_device *hdev,
 					struct sg_table *sgt)
 {
 	struct scatterlist *sg, *sg_next_iter;
-	u32 count, len, dma_desc_cnt, len_next;
+	u32 count, dma_desc_cnt;
+	u64 len, len_next;
 	dma_addr_t addr, addr_next;
 
 	dma_desc_cnt = 0;
@@ -3915,7 +3916,8 @@ static int goya_patch_dma_packet(struct hl_device *hdev,
 {
 	struct hl_userptr *userptr;
 	struct scatterlist *sg, *sg_next_iter;
-	u32 count, len, dma_desc_cnt, len_next;
+	u32 count, dma_desc_cnt;
+	u64 len, len_next;
 	dma_addr_t dma_addr, dma_addr_next;
 	enum goya_dma_direction user_dir;
 	u64 device_memory_addr, addr;
diff --git a/drivers/misc/habanalabs/goya/goyaP.h b/drivers/misc/habanalabs/goya/goyaP.h
index 7dc324e4e268..fd1476039226 100644
--- a/drivers/misc/habanalabs/goya/goyaP.h
+++ b/drivers/misc/habanalabs/goya/goyaP.h
@@ -122,7 +122,7 @@
 #define VA_DDR_SPACE_SIZE	(VA_DDR_SPACE_END - \
 					VA_DDR_SPACE_START)	/* 128GB */
 
-#define DMA_MAX_TRANSFER_SIZE	0xFFFFFFFF
+#define DMA_MAX_TRANSFER_SIZE	U32_MAX
 
 #define HW_CAP_PLL		0x00000001
 #define HW_CAP_DDR_0		0x00000002
-- 
2.18.0


                 reply	other threads:[~2019-02-24  9:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20190224095526.29183-1-oded.gabbay@gmail.com \
    --to=oded.gabbay@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rppt@linux.ibm.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

Powered by JetHome