mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	bpf: Fix a erroneous check after snprintf()
snprintf() does not return negative error code on error, it returns the
number of characters which *would* be generated for the given input.
Fix the error handling check.
Fixes: 57539b1c0a ("bpf: Enable annotating trusted nested pointers")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/393bdebc87b22563c08ace094defa7160eb7a6c0.1694190795.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
			
			
This commit is contained in:
		
							parent
							
								
									4eb94a7793
								
							
						
					
					
						commit
						a8f1257286
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		| 
						 | 
					@ -8501,7 +8501,7 @@ bool btf_nested_type_is_trusted(struct bpf_verifier_log *log,
 | 
				
			||||||
	tname = btf_name_by_offset(btf, walk_type->name_off);
 | 
						tname = btf_name_by_offset(btf, walk_type->name_off);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = snprintf(safe_tname, sizeof(safe_tname), "%s%s", tname, suffix);
 | 
						ret = snprintf(safe_tname, sizeof(safe_tname), "%s%s", tname, suffix);
 | 
				
			||||||
	if (ret < 0)
 | 
						if (ret >= sizeof(safe_tname))
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	safe_id = btf_find_by_name_kind(btf, safe_tname, BTF_INFO_KIND(walk_type->info));
 | 
						safe_id = btf_find_by_name_kind(btf, safe_tname, BTF_INFO_KIND(walk_type->info));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue