NFSv4: Clean up the nfs.callback_tcpport option

Tighten up the validity checking in param_set_port: check for NULL pointers.
Ensure that the option shows up on 'modinfo' output.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
Trond Myklebust 2009-08-09 15:06:19 -04:00
parent cbf1107126
commit c140aa9135

View File

@ -43,21 +43,29 @@ static struct svc_program nfs4_callback_program;
unsigned int nfs_callback_set_tcpport; unsigned int nfs_callback_set_tcpport;
unsigned short nfs_callback_tcpport; unsigned short nfs_callback_tcpport;
unsigned short nfs_callback_tcpport6; unsigned short nfs_callback_tcpport6;
static const int nfs_set_port_min = 0; #define NFS_CALLBACK_MAXPORTNR (65535U)
static const int nfs_set_port_max = 65535;
static int param_set_port(const char *val, struct kernel_param *kp) static int param_set_portnr(const char *val, struct kernel_param *kp)
{ {
char *endp; unsigned long num;
int num = simple_strtol(val, &endp, 0); int ret;
if (endp == val || *endp || num < nfs_set_port_min || num > nfs_set_port_max)
if (!val)
return -EINVAL; return -EINVAL;
*((int *)kp->arg) = num; ret = strict_strtoul(val, 0, &num);
if (ret == -EINVAL || num > NFS_CALLBACK_MAXPORTNR)
return -EINVAL;
*((unsigned int *)kp->arg) = num;
return 0; return 0;
} }
module_param_call(callback_tcpport, param_set_port, param_get_int, static int param_get_portnr(char *buffer, struct kernel_param *kp)
&nfs_callback_set_tcpport, 0644); {
return param_get_uint(buffer, kp);
}
#define param_check_portnr(name, p) __param_check(name, p, unsigned int);
module_param_named(callback_tcpport, nfs_callback_set_tcpport, portnr, 0644);
/* /*
* This is the NFSv4 callback kernel thread. * This is the NFSv4 callback kernel thread.