Commit f014165
scsi: iscsi: Fix possible memory leak when device_register() failed
If device_register() returns error, the name allocated by the
dev_set_name() need be freed. As described in the comment of
device_register(), we should use put_device() to give up the reference in
the error path.
Fix this by calling put_device(), the name will be freed in the
kobject_cleanup(), and this patch modified resources will be released by
calling the corresponding callback function in the device_release().
Signed-off-by: Zhou Guanghui <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Mike Christie <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>1 parent 0954256 commit f014165
1 file changed
+16
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
| 234 | + | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
| 248 | + | |
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
252 | 254 | | |
253 | 255 | | |
254 | 256 | | |
| |||
766 | 768 | | |
767 | 769 | | |
768 | 770 | | |
769 | | - | |
| 771 | + | |
770 | 772 | | |
771 | 773 | | |
772 | 774 | | |
| |||
780 | 782 | | |
781 | 783 | | |
782 | 784 | | |
783 | | - | |
784 | | - | |
785 | | - | |
| 785 | + | |
| 786 | + | |
786 | 787 | | |
787 | 788 | | |
788 | 789 | | |
| |||
1251 | 1252 | | |
1252 | 1253 | | |
1253 | 1254 | | |
1254 | | - | |
| 1255 | + | |
1255 | 1256 | | |
1256 | 1257 | | |
1257 | 1258 | | |
1258 | 1259 | | |
1259 | 1260 | | |
1260 | 1261 | | |
1261 | | - | |
1262 | | - | |
| 1262 | + | |
| 1263 | + | |
1263 | 1264 | | |
1264 | 1265 | | |
1265 | 1266 | | |
| |||
1299 | 1300 | | |
1300 | 1301 | | |
1301 | 1302 | | |
1302 | | - | |
| 1303 | + | |
1303 | 1304 | | |
1304 | 1305 | | |
1305 | 1306 | | |
1306 | 1307 | | |
1307 | 1308 | | |
1308 | 1309 | | |
1309 | | - | |
1310 | | - | |
| 1310 | + | |
| 1311 | + | |
1311 | 1312 | | |
1312 | 1313 | | |
1313 | 1314 | | |
| |||
4815 | 4816 | | |
4816 | 4817 | | |
4817 | 4818 | | |
4818 | | - | |
| 4819 | + | |
4819 | 4820 | | |
4820 | 4821 | | |
4821 | 4822 | | |
| |||
4850 | 4851 | | |
4851 | 4852 | | |
4852 | 4853 | | |
4853 | | - | |
4854 | | - | |
| 4854 | + | |
| 4855 | + | |
4855 | 4856 | | |
4856 | 4857 | | |
4857 | 4858 | | |
| |||
0 commit comments