summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-10-01tools: kwboot: Use a function to check whether received byte is a Xmodem replyMarek Behún
This is a non-functional change that should make the code more readable. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-10-01tools: kwboot: Split sending image into header and data stagesPali Rohár
This change is required to implement other features in kwboot. Split sending header and data parts of the image into two stages. Signed-off-by: Pali Rohár <pali@kernel.org> [ refactored ] Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-10-01tools: kwboot: Print newline on error when progress was not completedPali Rohár
When progress was not completed, current terminal position is in progress bar. So print newline before printing error message to make error message more readable. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-10-01tools: kwboot: Fix printing progressPali Rohár
Ensure that `pos` is still in range up to the `width` so printing 100% works also for bigger images. After printing 100% progress reset it to zero, so that next progressbar can be started. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-10-01tools: kwboot: Fix comparison of integers with different sizeMarek Behún
The compiler complains that we are comparing int with size_t when compiled with -W. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-10-01tools: kwboot: Fix return type of kwboot_xm_makeblock() functionPali Rohár
Function kwboot_xm_makeblock() always returns length of xmodem block. It is always non-negative and calculated from variable with size_t type. Set return type of this function to size_t and remove dead code which checks for negative value. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-10-01tools: kwboot: Fix kwboot_xm_sendblock() function when kwboot_tty_recv() failsPali Rohár
When kwboot_tty_recv() fails or times out, it does not set the `c` variable to NAK. The variable is then compared, while it holds either an undefined value or a value from previous iteration. Set `c` to NAK so that the other side will try to resend current block, and remove the now unnecessary break. In other failure cases return immediately. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-10-01tools: kwboot: Print version information headerPali Rohár
Print kwboot's (U-Boot's) version when printing usage. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-10-01tools: kwboot: Refactor and fix writing bufferMarek Behún
There are 3 instances in kwboot.c where we need to write() a given buffer whole (iteratively writing until all data are written), and 2 of those instances are wrong, for they do not increment the buffer pointer. Refactor the code into a new function kwboot_write() where it is fixed. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-10-01tools: kwboot: Make the quit sequence buffer constMarek Behún
This buffer is never written to. Make it const. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-10-01tools: kwboot: Fix buffer overflow in kwboot_terminal()Marek Behún
The `in` variable is set to -1 in kwboot_terminal() if stdin is not a tty. In this case we should not look whether -1 is set in fd_set, for it can lead to a buffer overflow, which can be reproduced with echo "xyz" | ./tools/kwboot -t /dev/ttyUSB0 Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-10-01tools: kwbimage: Fix printf format warningMarek Behún
On 32-bit ARM the compiler complains: tools/kwbimage.c:547: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ Fix this by using %zu instead of %lu format specifier. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-09-30Azure/GitLab CI: Update docker imageTom Rini
Rebuild our current docker image so that ca-certificates will be updated and Let's Encrypt issued certificates will work again. Signed-off-by: Tom Rini <trini@konsulko.com>
2021-09-30Merge tag 'xilinx-for-v2022.01-rc1' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-microblaze into next Xilinx changes for v2022.01-rc1 zynq: - Enable capsule update for qspi and mmc - Update zed DT qspi compatible string zynqmp: - Add missing modeboot for EMMC - Add missing nand DT properties - List all eeproms for SC on vck190 - Add vck190 SC psu_init clk: - Handle only GATE type clock for Versal watchdog: - Update versal driver to handle system reset
2021-09-30Merge branch '2021-09-30-whitespace-cleanups' into nextTom Rini
- A large number of whitespace cleanups from Wolfgang
2021-09-30WS cleanup: remove SPACE(s) followed by TABWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de>
2021-09-30WS cleanup: remove trailing white spaceWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-09-30WS cleanup: remove excessive empty linesWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de>
2021-09-30WS cleanup: remove trailing empty linesWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de>
2021-09-30watchdog: versal: Add support for expire nowAshok Reddy Soma
Wdt expire command makes the wdt to count least possible ticks(1) and expires immediately. Add expire_now option to the xlnx_wwdt_ops and implement it by calling xlnx_wwdt_start() with minimum possible count(1). Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com> Link: https://lore.kernel.org/r/1632808919-8600-3-git-send-email-ashok.reddy.soma@xilinx.com Signed-off-by: Michal Simek <michal.simek@xilinx.com>
2021-09-30watchdog: versal: Add support for basic window watchdogAshok Reddy Soma
Existing driver uses generic watchdog mode which generates a signal to PLM firmware, but the signal cannot be used to reset the system. Change driver to use window watchdog basic mode. This window watchdog mode generates a signal to PLM firmware which decides what action to take upon expiry of watchdog. Timeout value for xlnx_wwdt_start will come in milli seconds from wdt framework. Make changes to load count value accordingly. Add checks before loading the timer for min and max possible values. Fix authour email id of Ashok Reddy Soma to long email id. Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com> Link: https://lore.kernel.org/r/1632808919-8600-2-git-send-email-ashok.reddy.soma@xilinx.com Signed-off-by: Michal Simek <michal.simek@xilinx.com>
2021-09-30clk: versal: Enable only GATE type clocksT Karthik Reddy
Clocks should be enabled or disabled only if they are of GATE type clocks. If they are not of GATE type clocks, don't touch them. Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com> Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com> Link: https://lore.kernel.org/r/1632808827-6109-1-git-send-email-ashok.reddy.soma@xilinx.com Signed-off-by: Michal Simek <michal.simek@xilinx.com>
2021-09-30arm64: zynqmp: Add psu_init_gpl for vck190/vmk180 SCMichal Simek
Add psu_init_gpl file for getting SPL to work directly from the tree. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Link: https://lore.kernel.org/r/6675723ad52d29982e62c6ca4832ed18688076cb.1632488774.git.michal.simek@xilinx.com
2021-09-30arm64: zynqmp: Define all eeproms for SC on vck190Michal Simek
There are multiple eeproms on vck190 that's why list all of them. FMC eeproms are present only when fmcs are plugged. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Link: https://lore.kernel.org/r/96902661e3ab9e20b59d626e6129ccf6f3317c4d.1632488695.git.michal.simek@xilinx.com
2021-09-30arm: zynq: Use s25fl256s1 compatible string on zedboardMichal Simek
Use compatible string which is listed in the Linux kernel. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Link: https://lore.kernel.org/r/49bc6b056b0f6f69d4d90351dc875a66b7e37619.1631715748.git.michal.simek@xilinx.com
2021-09-30arm64: zynqmp: Add device tree properties for nand flashAmit Kumar Mahapatra
Add ecc strength & ecc step size properties for nand flash devices, when operating in software-ecc mode. Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Link: https://lore.kernel.org/r/866f4b888129ff0213df9cdb51b5529b199fb7b7.1631713594.git.michal.simek@xilinx.com
2021-09-30xilinx: zynqmp: Set modeboot env variable in eMMC bootmodeAshok Reddy Soma
Set environment variable modeboot to "emmcboot" in case of eMMC boot mode. Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Link: https://lore.kernel.org/r/c61231e4b8c6118862dfc82e923211637bf29991.1631688736.git.michal.simek@xilinx.com
2021-09-30ARM: zynq: Enable capsule update for qspi and mmcMichal Simek
Generate dfu_alt_info setup at runtime for capsule update. Enabling this feature will help with upgrading boards without remembering what is where. The similar change was done for ZynqMP by commit b86f43de0be0 ("xilinx: zynqmp: Add support for runtime dfu_alt_info setup"). Code needs to be enabled by CONFIG_SET_DFU_ALT_INFO. And also enable capsule on disk for RAW firmware images with efidebug command. Two indexes are supported for SPL flow. Images can be generated like: ./tools/mkeficapsule --raw spl/boot.bin --index 1 capsule1.bin ./tools/mkeficapsule --raw u-boot.img --index 2 capsule2.bin Then place them to SD card and load them: load mmc 0 10000000 capsule1.bin && efidebug capsule update -v 10000000 load mmc 0 10000000 capsule2.bin && efidebug capsule update -v 10000000 FSBL flow will also work where only index 1 capsule is used. There should be enough space for using boot.bin with bitstream too. Zynq also support multiple boot locations in SPI or MMC but it is not wired by this patch. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Link: https://lore.kernel.org/r/bea5fc75a87a5971f118b46bab4aa7ca39a629c6.1630061610.git.michal.simek@xilinx.com
2021-09-29Merge tag 'rpi-next-2021.10.2' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-raspberrypi - fix usb stopt; usb start; bug - update Nicolas email address
2021-09-29Merge https://source.denx.de/u-boot/custodians/u-boot-marvellTom Rini
- Armada8k: Fix CP0 eMMC/SDIO support (Robert)
2021-09-29arm: rpi: perform XHCI firmware upload only onceMarek Szyprowski
XHCI firmware upload must be performed only once after initializing the PCI bridge. This fixes USB stack initialization after calling "usb stop; usb start" on Raspberry Pi 4B. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
2021-09-29mailmap: Update mail address for Nicolas Saenz julienneNicolas Saenz Julienne
The @suse.de address doesn't exist anymore. Update it to something not dependent on my workplace. Signed-off-by: Nicolas Saenz Julienne <nsaenz@kernel.org> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
2021-09-29Merge branch 'network_master' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-net into next - Fix some non-NULL terminated strings in the networking subsystem - net: tsec: Mark tsec_get_interface as __maybe_unused
2021-09-29arm: dts: armada8040: Fix CP0 eMMC/SDIO supportRobert Marko
During the migration to a single DTSI for the CP110-s specific pinctrl compatibles were moved to the SoC DTSI as CP0 and CP1 have some specifics. Namely, CP0 eMMC/SDIO support depends on the mvebu-pinctrl driver setting the BIT(0) in eMMC PHY IO Control 0 Register to 0 in order for the connect the eMMC/SDIO PHY to the controller and not use it as a MPP pin multiplexor. So, the mvebu-pinctrl driver check specifically for the "marvell,armada-8k-cpm-pinctrl" compatible to clear the that bit. Issue is that compatibles in the 8040 DTSI were set to "marvell,8k-cpm-pinctrl" for CP0 and "marvell,8k-cps-pinctrl" for the CP1. This is obviously incorrect as the pinctrl driver does not know about these. So fix the regression by applying correct compatibles to the DTSI. Regression found and tested on the Puzzle M801 board. Fixes: a0ba97e5 ("arm: armada: dts: Use a single dtsi for cp110 die description") Signed-off-by: Robert Marko <robert.marko@sartura.hr> Reviewed-by: Stefan Roese <sr@denx.de>
2021-09-28Merge branch '2021-09-25-TI-platform-updates' into nextTom Rini
- Start moving some TI board docs to rST - Assorted TI-specific Kconfig migrations and namespace cleanups. This also allows for some code cleanups.
2021-09-28Merge tag '20210928-for-next' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-i2c into next i2c changes for 20210928-for-next - i2c: rcar_i2c: Enable configuring SCL rise and fall times - i2c: mvtwsi: Add support for DM clocks and resets - mtd: nand: raw: convert nand_dt_init() to ofnode_xx() interface
2021-09-28Merge branch '2021-09-28-regression-fixes'Tom Rini
- Reintroduce creating internally the "nor%d" style names, in order to fix some use U-Boot use-cases involving the "mtd" command. - Fix a regression over the default SPI bus mode shown by having the compiled default actually start being used. The correct default here is 0. - Fix ethernet on imx7d-sdb - Fix a regression with MTD NAND devices when OF_LIVE is enabled
2021-09-28imx: imx7d-sdb: fix ethernet, sync .dts with linuxRasmus Villemoes
Commit 0d52bab46 (mx7dsabre: Enable DM_ETH) changed these flags from 0 (aka GPIO_ACTIVE_HIGH) to GPIO_ACTIVE_LOW. It claimed to "Also sync device tree with v5.5-rc1", but in the linux tree, these gpios have always been GPIO_ACTIVE_HIGH ever since this node was introduced around v4.13 (linux commit 184f39b5). I'm guessing that the reason for the GPIO_ACTIVE_LOW was to work around the behaviour of the soft-spi driver back then, which effectively defaulted to spi-mode 3 and not 0. That was arguably a bug in the soft-spi driver, which then got fixed in 0e146993bb3 (spi: add support for all spi modes with soft spi), but that commit then broke ethernet on this board. Fix it by setting the gpios as active high, which as a bonus actually brings us in sync with the .dts in the linux source tree. Without this, one gets Net: Could not get PHY for FEC0: addr 0 No ethernet found. With this, ethernet (at least ping and tftp) works as expected from the U-Boot shell. Cc: Fabio Estevam <festevam@gmail.com> Cc: Joris Offouga <offougajoris@gmail.com> Cc: "Christian Bräuner Sørensen" <yocto@bsorensen.net> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2021-09-28mtd: nand: raw: convert nand_dt_init() to ofnode_xx() interfacePatrice Chotard
nand_dt_init() is still using fdtdec_xx() interface. If OF_LIVE flag is enabled, dt property can't be get anymore. Updating all fdtdec_xx() interface to ofnode_xx() to solve this issue. For doing this, node parameter type must be ofnode. First idea was to convert "node" parameter to ofnode type inside nand_dt_init() using offset_to_ofnode(node). But offset_to_ofnode() is not bijective, in case OF_LIVE flag is enabled, it performs an assert(). So, this leads to update nand_chip struct flash_node field from int to ofnode and to update all nand_dt_init() callers. Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
2021-09-28mtd: spi: Set CONFIG_SF_DEFAULT_MODE default to 0Marek Vasut
Before e2e95e5e254 ("spi: Update speed/mode on change") most systems silently defaulted to SF bus mode 0. Now the mode is always updated, which causes breakage. It seems most SF which are used as boot media operate in bus mode 0, so switch that as the default. This should fix booting at least on Altera SoCFPGA, ST STM32, Xilinx ZynqMP, NXP iMX and Rockchip SoCs, which recently ran into trouble with mode 3. Marvell Kirkwood and Xilinx microblaze need to be checked as those might need mode 3. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Aleksandar Gerasimovski <aleksandar.gerasimovski@hitachi-powergrids.com> Cc: Andreas Biessmann <andreas@biessmann.org> Cc: Eugen Hristev <eugen.hristev@microchip.com> Cc: Michal Simek <michal.simek@xilinx.com> Cc: Patrice Chotard <patrice.chotard@foss.st.com> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com> Cc: Peng Fan <peng.fan@nxp.com> Cc: Siew Chin Lim <elly.siew.chin.lim@intel.com> Cc: Tom Rini <trini@konsulko.com> Cc: Valentin Longchamp <valentin.longchamp@hitachi-powergrids.com> Cc: Vignesh Raghavendra <vigneshr@ti.com>
2021-09-28mtd: spi: nor: force mtd name to "nor%d"Patrick Delaunay
Force the mtd name of spi-nor to "nor" + the driver sequence number: "nor0", "nor1"... beginning after the existing nor devices. This patch is coherent with existing "nand" and "spi-nand" mtd device names. When CFI MTD NOR device are supported, the spi-nor index is chosen after the last CFI device defined by CONFIG_SYS_MAX_FLASH_BANKS. When CONFIG_SYS_MAX_FLASH_BANKS_DETECT is activated, this config is replaced by to cfi_flash_num_flash_banks in the include file mtd/cfi_flash.h. This generic name "nor%d" can be use to identify the mtd spi-nor device without knowing the real device name or the DT path of the device, used with API get_mtd_device_nm() and is used in mtdparts command. This patch also avoids issue when the same NOR device is present 2 times, for example on STM32MP15F-EV1: STM32MP> mtd list SF: Detected mx66l51235l with page size 256 Bytes, erase size 64 KiB, \ total 64 MiB List of MTD devices: * nand0 - type: NAND flash - block size: 0x40000 bytes - min I/O: 0x1000 bytes - OOB size: 224 bytes - OOB available: 118 bytes - ECC strength: 8 bits - ECC step size: 512 bytes - bitflip threshold: 6 bits - 0x000000000000-0x000040000000 : "nand0" * mx66l51235l - device: mx66l51235l@0 - parent: spi@58003000 - driver: jedec_spi_nor - path: /soc/spi@58003000/mx66l51235l@0 - type: NOR flash - block size: 0x10000 bytes - min I/O: 0x1 bytes - 0x000000000000-0x000004000000 : "mx66l51235l" * mx66l51235l - device: mx66l51235l@1 - parent: spi@58003000 - driver: jedec_spi_nor - path: /soc/spi@58003000/mx66l51235l@1 - type: NOR flash - block size: 0x10000 bytes - min I/O: 0x1 bytes - 0x000000000000-0x000004000000 : "mx66l51235l" The same mtd name "mx66l51235l" identify the 2 instances mx66l51235l@0 and mx66l51235l@1. This patch fixes a ST32CubeProgrammer / stm32prog command issue with nor0 target on STM32MP157C-EV1 board introduced by commit b7f060565e31 ("mtd: spi-nor: allow registering multiple MTDs when DM is enabled"). Fixes: b7f060565e31 ("mtd: spi-nor: allow registering multiple MTDs when DM is enabled") Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> [trini: Add <dm/device.h> to <mtd.h> for DM_MAX_SEQ_STR] Signed-off-by: Tom Rini <trini@konsulko.com>
2021-09-28scripts: ensure the cocci script for miiphy_register does not leak the MDIO busVladimir Oltean
When mdio_register fails, mdio_free should be called on the mdiodev that was previously allocated with mdio_alloc. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
2021-09-28arch: powerpc: mpc85xx: free MDIO bus if mdio_register failsVladimir Oltean
If mdio_register fails, it is nice to not leave behind dangling allocated memory. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
2021-09-28net: dsa: ensure port names are NULL-terminated after DSA_PORT_NAME_LENGTH ↵Vladimir Oltean
truncation strncpy() simply bails out when copying a source string whose size exceeds the destination string size, potentially leaving the destination string unterminated. One possible way to address is to pass DSA_PORT_NAME_LENGTH - 1 and a previously zero-initialized destination string, but this is more difficult to maintain. The chosen alternative is to use strlcpy(), which properly limits the copy len in the (srclen >= size) case to "size - 1", and which is also more efficient than the strncpy() byte-by-byte implementation by using memcpy. The destination string returned by strlcpy() is always NULL terminated. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
2021-09-28net: dsa: felix: check return code of mdio_alloc and mdio_registerVladimir Oltean
These functions can return errors, it's best to catch them and trigger the driver unwind code path. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
2021-09-28scripts: ensure the cocci script for miiphy_register does not leave ↵Vladimir Oltean
NULL-unterminated strings strncpy() simply bails out when copying a source string whose size exceeds the destination string size, potentially leaving the destination string unterminated. One possible way to address is to pass MDIO_NAME_LEN - 1 and a previously zero-initialized destination string, but this is more difficult to maintain. The chosen alternative is to use strlcpy(), which properly limits the copy len in the (srclen >= size) case to "size - 1", and which is also more efficient than the strncpy() byte-by-byte implementation by using memcpy. The destination string returned by strlcpy() is always NULL terminated. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
2021-09-28net: mdio-uclass: rewrite dm_mdio_post_probe using strlcpyVladimir Oltean
dm_mdio_post_probe used to be vulnerable after truncation, but has been patched by commit 398e7512d8d7 ("net: Fix Covarity Defect 244093"). Nonetheless, we can use strlcpy like the rest of the code base now, which yields the same result. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
2021-09-28net: qe: uec: ensure mdiodev->name is NULL terminated after MDIO_NAME_LEN ↵Vladimir Oltean
truncation strncpy() simply bails out when copying a source string whose size exceeds the destination string size, potentially leaving the destination string unterminated. One possible way to address is to pass MDIO_NAME_LEN - 1 and a previously zero-initialized destination string, but this is more difficult to maintain. The chosen alternative is to use strlcpy(), which properly limits the copy len in the (srclen >= size) case to "size - 1", and which is also more efficient than the strncpy() byte-by-byte implementation by using memcpy. The destination string returned by strlcpy() is always NULL terminated. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
2021-09-28net: davinci_emac: ensure mdiodev->name is NULL terminated after ↵Vladimir Oltean
MDIO_NAME_LEN truncation strncpy() simply bails out when copying a source string whose size exceeds the destination string size, potentially leaving the destination string unterminated. One possible way to address is to pass MDIO_NAME_LEN - 1 and a previously zero-initialized destination string, but this is more difficult to maintain. The chosen alternative is to use strlcpy(), which properly limits the copy len in the (srclen >= size) case to "size - 1", and which is also more efficient than the strncpy() byte-by-byte implementation by using memcpy. The destination string returned by strlcpy() is always NULL terminated. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
2021-09-28net: smc911x: ensure mdiodev->name is NULL terminated after MDIO_NAME_LEN ↵Vladimir Oltean
truncation strncpy() simply bails out when copying a source string whose size exceeds the destination string size, potentially leaving the destination string unterminated. One possible way to address is to pass MDIO_NAME_LEN - 1 and a previously zero-initialized destination string, but this is more difficult to maintain. The chosen alternative is to use strlcpy(), which properly limits the copy len in the (srclen >= size) case to "size - 1", and which is also more efficient than the strncpy() byte-by-byte implementation by using memcpy. The destination string returned by strlcpy() is always NULL terminated. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>