Skip to content

Commit b6fe6f0

Browse files
GeHao01994kuba-moo
authored andcommitted
dpll: Fix potential msg memleak when genlmsg_put_reply failed
We should clean the skb resource if genlmsg_put_reply failed. Fixes: 9d71b54 ("dpll: netlink: Add DPLL framework base functions") Signed-off-by: Hao Ge <[email protected]> Reviewed-by: Vadim Fedorenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b2d6664 commit b6fe6f0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/dpll/dpll_netlink.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,9 +1093,10 @@ int dpll_nl_pin_id_get_doit(struct sk_buff *skb, struct genl_info *info)
10931093
return -ENOMEM;
10941094
hdr = genlmsg_put_reply(msg, info, &dpll_nl_family, 0,
10951095
DPLL_CMD_PIN_ID_GET);
1096-
if (!hdr)
1096+
if (!hdr) {
1097+
nlmsg_free(msg);
10971098
return -EMSGSIZE;
1098-
1099+
}
10991100
pin = dpll_pin_find_from_nlattr(info);
11001101
if (!IS_ERR(pin)) {
11011102
ret = dpll_msg_add_pin_handle(msg, pin);
@@ -1123,8 +1124,10 @@ int dpll_nl_pin_get_doit(struct sk_buff *skb, struct genl_info *info)
11231124
return -ENOMEM;
11241125
hdr = genlmsg_put_reply(msg, info, &dpll_nl_family, 0,
11251126
DPLL_CMD_PIN_GET);
1126-
if (!hdr)
1127+
if (!hdr) {
1128+
nlmsg_free(msg);
11271129
return -EMSGSIZE;
1130+
}
11281131
ret = dpll_cmd_pin_get_one(msg, pin, info->extack);
11291132
if (ret) {
11301133
nlmsg_free(msg);
@@ -1256,8 +1259,10 @@ int dpll_nl_device_id_get_doit(struct sk_buff *skb, struct genl_info *info)
12561259
return -ENOMEM;
12571260
hdr = genlmsg_put_reply(msg, info, &dpll_nl_family, 0,
12581261
DPLL_CMD_DEVICE_ID_GET);
1259-
if (!hdr)
1262+
if (!hdr) {
1263+
nlmsg_free(msg);
12601264
return -EMSGSIZE;
1265+
}
12611266

12621267
dpll = dpll_device_find_from_nlattr(info);
12631268
if (!IS_ERR(dpll)) {
@@ -1284,8 +1289,10 @@ int dpll_nl_device_get_doit(struct sk_buff *skb, struct genl_info *info)
12841289
return -ENOMEM;
12851290
hdr = genlmsg_put_reply(msg, info, &dpll_nl_family, 0,
12861291
DPLL_CMD_DEVICE_GET);
1287-
if (!hdr)
1292+
if (!hdr) {
1293+
nlmsg_free(msg);
12881294
return -EMSGSIZE;
1295+
}
12891296

12901297
ret = dpll_device_get_one(dpll, msg, info->extack);
12911298
if (ret) {

0 commit comments

Comments
 (0)