mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	nfsd: clean up expkey_parse error cases
We might as well do all of these at the end. Fix up a couple minor style nits while we're there. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
This commit is contained in:
		
							parent
							
								
									6dfcde98a2
								
							
						
					
					
						commit
						30bc4dfd3b
					
				
					 1 changed files with 11 additions and 14 deletions
				
			
		| 
						 | 
					@ -99,7 +99,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
 | 
				
			||||||
	int fsidtype;
 | 
						int fsidtype;
 | 
				
			||||||
	char *ep;
 | 
						char *ep;
 | 
				
			||||||
	struct svc_expkey key;
 | 
						struct svc_expkey key;
 | 
				
			||||||
	struct svc_expkey *ek;
 | 
						struct svc_expkey *ek = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (mesg[mlen-1] != '\n')
 | 
						if (mesg[mlen-1] != '\n')
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
| 
						 | 
					@ -107,7 +107,8 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 | 
						buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 | 
				
			||||||
	err = -ENOMEM;
 | 
						err = -ENOMEM;
 | 
				
			||||||
	if (!buf) goto out;
 | 
						if (!buf)
 | 
				
			||||||
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = -EINVAL;
 | 
						err = -EINVAL;
 | 
				
			||||||
	if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
 | 
						if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
 | 
				
			||||||
| 
						 | 
					@ -151,38 +152,34 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* now we want a pathname, or empty meaning NEGATIVE  */
 | 
						/* now we want a pathname, or empty meaning NEGATIVE  */
 | 
				
			||||||
	err = -EINVAL;
 | 
						err = -EINVAL;
 | 
				
			||||||
	if ((len=qword_get(&mesg, buf, PAGE_SIZE)) < 0) {
 | 
						len = qword_get(&mesg, buf, PAGE_SIZE);
 | 
				
			||||||
		cache_put(&ek->h, &svc_expkey_cache);
 | 
						if (len < 0)
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	dprintk("Path seems to be <%s>\n", buf);
 | 
						dprintk("Path seems to be <%s>\n", buf);
 | 
				
			||||||
	err = 0;
 | 
						err = 0;
 | 
				
			||||||
	if (len == 0) {
 | 
						if (len == 0) {
 | 
				
			||||||
		set_bit(CACHE_NEGATIVE, &key.h.flags);
 | 
							set_bit(CACHE_NEGATIVE, &key.h.flags);
 | 
				
			||||||
		ek = svc_expkey_update(&key, ek);
 | 
							ek = svc_expkey_update(&key, ek);
 | 
				
			||||||
		if (ek)
 | 
							if (!ek)
 | 
				
			||||||
			cache_put(&ek->h, &svc_expkey_cache);
 | 
								err = -ENOMEM;
 | 
				
			||||||
		else err = -ENOMEM;
 | 
					 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		struct nameidata nd;
 | 
							struct nameidata nd;
 | 
				
			||||||
		err = path_lookup(buf, 0, &nd);
 | 
							err = path_lookup(buf, 0, &nd);
 | 
				
			||||||
		if (err) {
 | 
							if (err)
 | 
				
			||||||
			cache_put(&ek->h, &svc_expkey_cache);
 | 
					 | 
				
			||||||
			goto out;
 | 
								goto out;
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		dprintk("Found the path %s\n", buf);
 | 
							dprintk("Found the path %s\n", buf);
 | 
				
			||||||
		key.ek_path = nd.path;
 | 
							key.ek_path = nd.path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ek = svc_expkey_update(&key, ek);
 | 
							ek = svc_expkey_update(&key, ek);
 | 
				
			||||||
		if (ek)
 | 
							if (!ek)
 | 
				
			||||||
			cache_put(&ek->h, &svc_expkey_cache);
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			err = -ENOMEM;
 | 
								err = -ENOMEM;
 | 
				
			||||||
		path_put(&nd.path);
 | 
							path_put(&nd.path);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	cache_flush();
 | 
						cache_flush();
 | 
				
			||||||
 out:
 | 
					 out:
 | 
				
			||||||
 | 
						if (ek)
 | 
				
			||||||
 | 
							cache_put(&ek->h, &svc_expkey_cache);
 | 
				
			||||||
	if (dom)
 | 
						if (dom)
 | 
				
			||||||
		auth_domain_put(dom);
 | 
							auth_domain_put(dom);
 | 
				
			||||||
	kfree(buf);
 | 
						kfree(buf);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue