mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-10-29 05:40:12 -04:00 
			
		
		
		
	backend/drm: handle errors when fetching DRM name/version
These functions can fail if the FD is not a DRM device or on memory allocation failure, for instance.
This commit is contained in:
		
							parent
							
								
									82b4bc3f5f
								
							
						
					
					
						commit
						3aef433f97
					
				
					 1 changed files with 10 additions and 0 deletions
				
			
		|  | @ -171,7 +171,17 @@ struct wlr_backend *wlr_drm_backend_create(struct wlr_session *session, | |||
| 	assert(!parent || wlr_backend_is_drm(parent)); | ||||
| 
 | ||||
| 	char *name = drmGetDeviceNameFromFd2(dev->fd); | ||||
| 	if (name == NULL) { | ||||
| 		wlr_log_errno(WLR_ERROR, "drmGetDeviceNameFromFd2() failed"); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
| 	drmVersion *version = drmGetVersion(dev->fd); | ||||
| 	if (version == NULL) { | ||||
| 		wlr_log_errno(WLR_ERROR, "drmGetVersion() failed"); | ||||
| 		free(name); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 	wlr_log(WLR_INFO, "Initializing DRM backend for %s (%s)", name, version->name); | ||||
| 	drmFreeVersion(version); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Simon Ser
						Simon Ser