Commit 1c3333a
committed
cxl/mem: Do not rely on device_add() side effects for dev_set_name() failures
While device_add() will happen to catch dev_set_name() failures it is a
broken pattern to follow given that the core may try to fall back to a
different name.
Add explicit checking for dev_set_name() failures to be cleaned up by
put_device(). Skip cdev_device_add() and proceed directly to
put_device() if the name set fails.
This type of bug is easier to see if 'alloc' is split from 'add'
operations that require put_device() on failure. So cxl_memdev_alloc()
is split out as a result.
Fixes: b39cb10 ("cxl/mem: Register CXL memX devices")
Reported-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/161728760514.2474381.1163928273337158134.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>1 parent 5877515 commit 1c3333a
1 file changed
+29
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1180 | 1180 | | |
1181 | 1181 | | |
1182 | 1182 | | |
1183 | | - | |
| 1183 | + | |
1184 | 1184 | | |
1185 | 1185 | | |
1186 | 1186 | | |
| |||
1190 | 1190 | | |
1191 | 1191 | | |
1192 | 1192 | | |
1193 | | - | |
| 1193 | + | |
1194 | 1194 | | |
1195 | 1195 | | |
1196 | 1196 | | |
1197 | | - | |
| 1197 | + | |
1198 | 1198 | | |
1199 | 1199 | | |
1200 | 1200 | | |
| |||
1203 | 1203 | | |
1204 | 1204 | | |
1205 | 1205 | | |
1206 | | - | |
1207 | 1206 | | |
1208 | 1207 | | |
1209 | 1208 | | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
1210 | 1231 | | |
1211 | 1232 | | |
1212 | 1233 | | |
1213 | 1234 | | |
1214 | 1235 | | |
1215 | 1236 | | |
1216 | 1237 | | |
| 1238 | + | |
1217 | 1239 | | |
1218 | 1240 | | |
1219 | | - | |
| 1241 | + | |
1220 | 1242 | | |
1221 | 1243 | | |
1222 | 1244 | | |
1223 | 1245 | | |
1224 | | - | |
| 1246 | + | |
1225 | 1247 | | |
1226 | 1248 | | |
1227 | 1249 | | |
1228 | 1250 | | |
1229 | 1251 | | |
1230 | | - | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
| 1252 | + | |
1234 | 1253 | | |
1235 | 1254 | | |
1236 | 1255 | | |
| |||
0 commit comments