Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommu/omap: Check for failure of a call to omap_iommu_dump_ctx

It is possible for the call to omap_iommu_dump_ctx to return
a negative error number, so check for the failure and return
the error number rather than pass the negative value to
simple_read_from_buffer.

Fixes: 14e0e6796a0d ("OMAP: iommu: add initial debugfs support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20200714192211.744776-1-colin.king@canonical.com
Addresses-Coverity: ("Improper use of negative value")
Signed-off-by: Joerg Roedel <jroedel@suse.de>

authored by

Colin Ian King and committed by
Joerg Roedel
dee9d154 f512eefc

+3
+3
drivers/iommu/omap-iommu-debug.c
··· 98 98 mutex_lock(&iommu_debug_lock); 99 99 100 100 bytes = omap_iommu_dump_ctx(obj, p, count); 101 + if (bytes < 0) 102 + goto err; 101 103 bytes = simple_read_from_buffer(userbuf, count, ppos, buf, bytes); 102 104 105 + err: 103 106 mutex_unlock(&iommu_debug_lock); 104 107 kfree(buf); 105 108