@@ -258,7 +258,9 @@ impl DevicePathFromTextProtocol {
258
258
str_to_utf16_ptr ( path)
259
259
. map ( |utf16_str| {
260
260
let out = unsafe { & * ( ( self . text_to_device_path_node ) ( utf16_str) ) } ;
261
- :: get_system_table ( ) . boot_services ( ) . free_pool ( utf16_str) ;
261
+ // FIXME(csssuf)
262
+ // Ideally, at this point, we'd free utf16_str. However, free_pool(utf16_str) seems
263
+ // to hang here for unknown reasons. So we leak it.
262
264
out
263
265
} )
264
266
}
@@ -267,7 +269,9 @@ impl DevicePathFromTextProtocol {
267
269
str_to_utf16_ptr ( path)
268
270
. map ( |utf16_str| {
269
271
let out = unsafe { & * ( ( self . text_to_device_path ) ( utf16_str) ) } ;
270
- :: get_system_table ( ) . boot_services ( ) . free_pool ( utf16_str) ;
272
+ // FIXME(csssuf)
273
+ // Ideally, at this point, we'd free utf16_str. However, free_pool(utf16_str) seems
274
+ // to hang here for unknown reasons. So we leak it.
271
275
out
272
276
} )
273
277
}
@@ -278,7 +282,7 @@ pub struct DevicePathUtilitiesProtocol {
278
282
get_device_path_size : * const CVoid ,
279
283
duplicate_device_path : * const CVoid ,
280
284
append_device_path : unsafe extern "win64" fn ( src1 : * const DevicePathProtocol , src2 : * const DevicePathProtocol ) -> * const DevicePathProtocol ,
281
- append_device_node : * const CVoid ,
285
+ append_device_node : unsafe extern "win64" fn ( path : * const DevicePathProtocol , node : * const DevicePathProtocol ) -> * const DevicePathProtocol ,
282
286
append_device_path_instance : * const CVoid ,
283
287
get_next_device_path_instance : * const CVoid ,
284
288
is_device_path_multi_instance : * const CVoid ,
@@ -296,7 +300,23 @@ impl DevicePathUtilitiesProtocol {
296
300
unsafe {
297
301
let out = ( self . append_device_path ) ( src1, src2) ;
298
302
if out == 0 as * const DevicePathProtocol {
299
- return Err ( Status :: InvalidParameter ) ;
303
+ // `out` being a null pointer indicates, according to the spec, that "memory could
304
+ // not be allocate[sic]." Whether that's due to memory conditions, bad parameters
305
+ // being passed in, or another reason is unspecified. Unless the caller passes in
306
+ // a massive DevicePathProtocol, it's unlikely that it's due to the actual
307
+ // parameters, so error here is represented as OutOfResources.
308
+ return Err ( Status :: OutOfResources ) ;
309
+ }
310
+ Ok ( out)
311
+ }
312
+ }
313
+
314
+ pub fn append_device_node ( & self , path : * const DevicePathProtocol , node : * const DevicePathProtocol ) -> Result < * const DevicePathProtocol , Status > {
315
+ unsafe {
316
+ let out = ( self . append_device_node ) ( path, node) ;
317
+ if out == 0 as * const DevicePathProtocol {
318
+ // See comment in append_device_path.
319
+ return Err ( Status :: OutOfResources ) ;
300
320
}
301
321
Ok ( out)
302
322
}
0 commit comments