diff options
author | Dan Carpenter <error27@gmail.com> | 2023-01-18 13:28:21 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-01-19 18:57:16 -0800 |
commit | a76e88c2942575bc43ea88d0f05d245b26859130 (patch) | |
tree | ecb85181fb789ac7cf59787cfc9bc1438fdb53c7 | |
parent | 482acbd68ea391b7a4033c90a50b9cf680afbe93 (diff) | |
download | lwn-a76e88c2942575bc43ea88d0f05d245b26859130.tar.gz lwn-a76e88c2942575bc43ea88d0f05d245b26859130.zip |
net: dsa: microchip: ptp: Fix error code in ksz_hwtstamp_set()
We want to return negative error codes here but the copy_to/from_user()
functions return the number of bytes remaining to be copied.
Fixes: c59e12a140fb ("net: dsa: microchip: ptp: Initial hardware time stamping support")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://lore.kernel.org/r/Y8fJxSvbl7UNVHh/@kili
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r-- | drivers/net/dsa/microchip/ksz_ptp.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c index a66a256f8814..4e22a695a64c 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -416,9 +416,8 @@ int ksz_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr) prt = &dev->ports[port]; - ret = copy_from_user(&config, ifr->ifr_data, sizeof(config)); - if (ret) - return ret; + if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) + return -EFAULT; ret = ksz_set_hwtstamp_config(dev, prt, &config); if (ret) @@ -426,7 +425,10 @@ int ksz_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr) memcpy(&prt->tstamp_config, &config, sizeof(config)); - return copy_to_user(ifr->ifr_data, &config, sizeof(config)); + if (copy_to_user(ifr->ifr_data, &config, sizeof(config))) + return -EFAULT; + + return 0; } static ktime_t ksz_tstamp_reconstruct(struct ksz_device *dev, ktime_t tstamp) |