[openwrt/openwrt] kernel: ltq-adsl-mei: fix compilation warning for copy_from_user ret

LEDE Commits lede-commits at lists.infradead.org
Thu May 11 18:25:14 PDT 2023


ansuel pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/d3207b13f84de30e71f7b5dc83d5d1d9e53e7191

commit d3207b13f84de30e71f7b5dc83d5d1d9e53e7191
Author: Christian Marangi <ansuelsmth at gmail.com>
AuthorDate: Tue May 9 16:26:34 2023 +0200

    kernel: ltq-adsl-mei: fix compilation warning for copy_from_user ret
    
    Fix compilation warning for copy_from_user ret value not handled.
    Fix compilation warning:
    /__w/openwrt/openwrt/openwrt/build_dir/target-mips_mips32_musl/linux-lantiq_ase/ltq-adsl-mei-ase/ltq-adsl-mei/drv_mei_cpe.c: In function 'DSL_BSP_FWDownload':
    /__w/openwrt/openwrt/openwrt/build_dir/target-mips_mips32_musl/linux-lantiq_ase/ltq-adsl-mei-ase/ltq-adsl-mei/drv_mei_cpe.c:1623:17: error: ignoring return value of 'copy_from_user' declared with attribute 'warn_unused_result' [-Werror=unused-result]
     1623 |                 copy_from_user ((char *) &img_hdr_tmp, buf, sizeof (img_hdr_tmp));
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /__w/openwrt/openwrt/openwrt/build_dir/target-mips_mips32_musl/linux-lantiq_ase/ltq-adsl-mei-ase/ltq-adsl-mei/drv_mei_cpe.c:1701:17: error: ignoring return value of 'copy_from_user' declared with attribute 'warn_unused_result' [-Werror=unused-result]
     1701 |                 copy_from_user (mem_ptr, buf + nRead, nCopy);
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
    
    Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
---
 package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c b/package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c
index 2339d919b6..8ccfb443ed 100644
--- a/package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c
+++ b/package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c
@@ -1620,7 +1620,9 @@ DSL_BSP_FWDownload (DSL_DEV_Device_t * pDev, const char *buf,
 			IFX_MEI_EMSG ("Firmware size is too small!\n");
 			return retval;
 		}
-		copy_from_user ((char *) &img_hdr_tmp, buf, sizeof (img_hdr_tmp));
+		if (copy_from_user ((char *) &img_hdr_tmp, buf, sizeof (img_hdr_tmp)))
+			return -EFAULT;
+
 		// header of image_size and crc are not included.
 		DSL_DEV_PRIVATE(pDev)->image_size = le32_to_cpu (img_hdr_tmp.size) + 8;
 
@@ -1698,7 +1700,9 @@ DSL_BSP_FWDownload (DSL_DEV_Device_t * pDev, const char *buf,
 			nCopy = SDRAM_SEGMENT_SIZE - offset;
 		else
 			nCopy = size - nRead;
-		copy_from_user (mem_ptr, buf + nRead, nCopy);
+		if (copy_from_user (mem_ptr, buf + nRead, nCopy))
+			return -EFAULT;
+
 		for (offset = 0; offset < (nCopy / 4); offset++) {
 			((unsigned long *) mem_ptr)[offset] = le32_to_cpu (((unsigned long *) mem_ptr)[offset]);
 		}




More information about the lede-commits mailing list