.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
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. |
---|
6 | 3 | * |
---|
7 | 4 | * Copyright (C) Alan Cox GW4PTS (alan@lxorguk.ukuu.org.uk) |
---|
8 | 5 | * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk) |
---|
.. | .. |
---|
78 | 75 | ax25_dev *ax25_dev; |
---|
79 | 76 | int i; |
---|
80 | 77 | |
---|
81 | | - if ((ax25_dev = ax25_addr_ax25dev(&route->port_addr)) == NULL) |
---|
82 | | - return -EINVAL; |
---|
83 | 78 | if (route->digi_count > AX25_MAX_DIGIS) |
---|
| 79 | + return -EINVAL; |
---|
| 80 | + |
---|
| 81 | + ax25_dev = ax25_addr_ax25dev(&route->port_addr); |
---|
| 82 | + if (!ax25_dev) |
---|
84 | 83 | return -EINVAL; |
---|
85 | 84 | |
---|
86 | 85 | write_lock_bh(&ax25_route_lock); |
---|
.. | .. |
---|
94 | 93 | if (route->digi_count != 0) { |
---|
95 | 94 | if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) { |
---|
96 | 95 | write_unlock_bh(&ax25_route_lock); |
---|
| 96 | + ax25_dev_put(ax25_dev); |
---|
97 | 97 | return -ENOMEM; |
---|
98 | 98 | } |
---|
99 | 99 | ax25_rt->digipeat->lastrepeat = -1; |
---|
.. | .. |
---|
104 | 104 | } |
---|
105 | 105 | } |
---|
106 | 106 | write_unlock_bh(&ax25_route_lock); |
---|
| 107 | + ax25_dev_put(ax25_dev); |
---|
107 | 108 | return 0; |
---|
108 | 109 | } |
---|
109 | 110 | ax25_rt = ax25_rt->next; |
---|
.. | .. |
---|
111 | 112 | |
---|
112 | 113 | if ((ax25_rt = kmalloc(sizeof(ax25_route), GFP_ATOMIC)) == NULL) { |
---|
113 | 114 | write_unlock_bh(&ax25_route_lock); |
---|
| 115 | + ax25_dev_put(ax25_dev); |
---|
114 | 116 | return -ENOMEM; |
---|
115 | 117 | } |
---|
116 | 118 | |
---|
.. | .. |
---|
123 | 125 | if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) { |
---|
124 | 126 | write_unlock_bh(&ax25_route_lock); |
---|
125 | 127 | kfree(ax25_rt); |
---|
| 128 | + ax25_dev_put(ax25_dev); |
---|
126 | 129 | return -ENOMEM; |
---|
127 | 130 | } |
---|
128 | 131 | ax25_rt->digipeat->lastrepeat = -1; |
---|
.. | .. |
---|
135 | 138 | ax25_rt->next = ax25_route_list; |
---|
136 | 139 | ax25_route_list = ax25_rt; |
---|
137 | 140 | write_unlock_bh(&ax25_route_lock); |
---|
| 141 | + ax25_dev_put(ax25_dev); |
---|
138 | 142 | |
---|
139 | 143 | return 0; |
---|
140 | 144 | } |
---|
.. | .. |
---|
176 | 180 | } |
---|
177 | 181 | } |
---|
178 | 182 | write_unlock_bh(&ax25_route_lock); |
---|
| 183 | + ax25_dev_put(ax25_dev); |
---|
179 | 184 | |
---|
180 | 185 | return 0; |
---|
181 | 186 | } |
---|
.. | .. |
---|
218 | 223 | |
---|
219 | 224 | out: |
---|
220 | 225 | write_unlock_bh(&ax25_route_lock); |
---|
| 226 | + ax25_dev_put(ax25_dev); |
---|
221 | 227 | return err; |
---|
222 | 228 | } |
---|
223 | 229 | |
---|