]> git.baikalelectronics.ru Git - kernel.git/commitdiff
yam: fix a memory leak in yam_siocdevprivate()
authorHangyu Hua <hbh25y@gmail.com>
Mon, 24 Jan 2022 03:29:54 +0000 (11:29 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 25 Jan 2022 11:04:55 +0000 (11:04 +0000)
ym needs to be free when ym->cmd != SIOCYAMSMCS.

Fixes: 0781168e23a2 ("yam: fix a missing-check bug")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hamradio/yam.c

index 6376b8485976cf454ebf9e8a4939c708f3116bd1..980f2be32f05a1974c13aba7d44f257901ed8cd6 100644 (file)
@@ -950,9 +950,7 @@ static int yam_siocdevprivate(struct net_device *dev, struct ifreq *ifr, void __
                ym = memdup_user(data, sizeof(struct yamdrv_ioctl_mcs));
                if (IS_ERR(ym))
                        return PTR_ERR(ym);
-               if (ym->cmd != SIOCYAMSMCS)
-                       return -EINVAL;
-               if (ym->bitrate > YAM_MAXBITRATE) {
+               if (ym->cmd != SIOCYAMSMCS || ym->bitrate > YAM_MAXBITRATE) {
                        kfree(ym);
                        return -EINVAL;
                }