File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -233,8 +233,18 @@ PciDevice_new_op
233233{
234234 DEBUG_PRINTF (PDADEBUG_ENTER , "" );
235235 extern char uio_sysfs_dir [PDA_STRING_LIMIT ];
236-
237- PciDevice * device = PciDevice_new_int ();
236+ PciDevice * device = NULL ;
237+
238+ /** Make sure requested device is owend by the driver **/
239+ DEBUG_PRINTF (PDADEBUG_VALUE , "Searching device %s/%s\n" , uio_sysfs_dir , uio_sysfs_entry );
240+ char file_path [PDA_STRING_LIMIT ];
241+ snprintf (file_path , PDA_STRING_LIMIT , "%s/%s" ,
242+ uio_sysfs_dir , uio_sysfs_entry );
243+ if (access (file_path , F_OK ) != 0 )
244+ { ERROR_EXIT ( ENODEV , exit , "No such device owned by driver!\n" ); }
245+
246+ /** Initialize device **/
247+ device = PciDevice_new_int ();
238248 if (device == NULL )
239249 { ERROR_EXIT ( ENODEV , exit , "Memory allocation failed!\n" ); }
240250
You can’t perform that action at this time.
0 commit comments