hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/net/ax25/ax25_route.c
....@@ -1,8 +1,5 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
2
- * This program is free software; you can redistribute it and/or modify
3
- * it under the terms of the GNU General Public License as published by
4
- * the Free Software Foundation; either version 2 of the License, or
5
- * (at your option) any later version.
63 *
74 * Copyright (C) Alan Cox GW4PTS (alan@lxorguk.ukuu.org.uk)
85 * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
....@@ -78,9 +75,11 @@
7875 ax25_dev *ax25_dev;
7976 int i;
8077
81
- if ((ax25_dev = ax25_addr_ax25dev(&route->port_addr)) == NULL)
82
- return -EINVAL;
8378 if (route->digi_count > AX25_MAX_DIGIS)
79
+ return -EINVAL;
80
+
81
+ ax25_dev = ax25_addr_ax25dev(&route->port_addr);
82
+ if (!ax25_dev)
8483 return -EINVAL;
8584
8685 write_lock_bh(&ax25_route_lock);
....@@ -94,6 +93,7 @@
9493 if (route->digi_count != 0) {
9594 if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
9695 write_unlock_bh(&ax25_route_lock);
96
+ ax25_dev_put(ax25_dev);
9797 return -ENOMEM;
9898 }
9999 ax25_rt->digipeat->lastrepeat = -1;
....@@ -104,6 +104,7 @@
104104 }
105105 }
106106 write_unlock_bh(&ax25_route_lock);
107
+ ax25_dev_put(ax25_dev);
107108 return 0;
108109 }
109110 ax25_rt = ax25_rt->next;
....@@ -111,6 +112,7 @@
111112
112113 if ((ax25_rt = kmalloc(sizeof(ax25_route), GFP_ATOMIC)) == NULL) {
113114 write_unlock_bh(&ax25_route_lock);
115
+ ax25_dev_put(ax25_dev);
114116 return -ENOMEM;
115117 }
116118
....@@ -123,6 +125,7 @@
123125 if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
124126 write_unlock_bh(&ax25_route_lock);
125127 kfree(ax25_rt);
128
+ ax25_dev_put(ax25_dev);
126129 return -ENOMEM;
127130 }
128131 ax25_rt->digipeat->lastrepeat = -1;
....@@ -135,6 +138,7 @@
135138 ax25_rt->next = ax25_route_list;
136139 ax25_route_list = ax25_rt;
137140 write_unlock_bh(&ax25_route_lock);
141
+ ax25_dev_put(ax25_dev);
138142
139143 return 0;
140144 }
....@@ -176,6 +180,7 @@
176180 }
177181 }
178182 write_unlock_bh(&ax25_route_lock);
183
+ ax25_dev_put(ax25_dev);
179184
180185 return 0;
181186 }
....@@ -218,6 +223,7 @@
218223
219224 out:
220225 write_unlock_bh(&ax25_route_lock);
226
+ ax25_dev_put(ax25_dev);
221227 return err;
222228 }
223229