netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] yam: fix a memory leak in yam_siocdevprivate()
@ 2022-01-24  3:29 Hangyu Hua
  2022-01-25 16:46 ` patchwork-bot+netdevbpf
  2022-01-27  3:59 ` Thomas Osterried
  0 siblings, 2 replies; 3+ messages in thread
From: Hangyu Hua @ 2022-01-24  3:29 UTC (permalink / raw)
  To: jpr, davem, kuba, wang6495; +Cc: linux-hams, netdev, linux-kernel, Hangyu Hua

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>
---
 drivers/net/hamradio/yam.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 6376b8485976..980f2be32f05 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -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;
 		}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-27  4:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24  3:29 [PATCH] yam: fix a memory leak in yam_siocdevprivate() Hangyu Hua
2022-01-25 16:46 ` patchwork-bot+netdevbpf
2022-01-27  3:59 ` Thomas Osterried

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).