Skip to contentSkip to conversation

media: staging: ipu3: img-mmu: fix sign-to-unsigned conversion

PATCH Superseded Richard Lyu 1 participant 1 message Mar 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: staging: ipu3: img-mmu: fix sign-to-unsigned conversion

imgu_mmu_unmap() returns size_t (unsigned), representing the number of bytes successfully unmapped. However, when the alignment check fails, it currently returns -EINVAL.

On 64-bit systems, this negative error code is implicitly converted to a very large unsigned value (18446744073709551594). The same happens on 32-bit systems as well, although the resulting value is smaller.

Return 0 when the alignment check fails to correctly indicate that no bytes were unmapped while resolving the following -Wsign-conversion warning:

drivers/staging/media/ipu3/ipu3-mmu.c:393:24: warning: unsigned conversion from 'int' to 'size_t' {aka 'long unsigned int'} changes value from '-22' to '18446744073709551594' [-Wsign-conversion]
393 | return -EINVAL;

All callers ignore the return value, so this change does not affect existing behavior.

Fixes 26f5689592e2 ("media: staging/intel-ipu3: mmu: Implement driver")
---
 drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/ipu3/ipu3-mmu.c +1 -1
index b196a5815903..fcea125e5935 100644
@@ -390,7 +390,7 @@ size_t imgu_mmu_unmap(struct imgu_mmu_info *info, unsigned long iova,
 	if (!IS_ALIGNED(iova | size, IPU3_PAGE_SIZE)) {
 		dev_err(mmu->dev, "unaligned: iova 0x%lx size 0x%zx\n",
 			iova, size);
-		return -EINVAL;
+		return 0;
 	}
 
 	dev_dbg(mmu->dev, "unmap this: iova 0x%lx size 0x%zx\n", iova, size);
Signature · 1 line
2.51.0