Skip to content

Commit

Permalink
yam: fix a memory leak in yam_siocdevprivate()
Browse files Browse the repository at this point in the history
ym needs to be free when ym->cmd != SIOCYAMSMCS.

Fixes: 0781168 ("yam: fix a missing-check bug")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
HBh25Y authored and davem330 committed Jan 25, 2022
1 parent c74ead2 commit 29eb315
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/net/hamradio/yam.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 29eb315

Please sign in to comment.