X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fsbus%2Fchar%2Fopenprom.c;h=239e108b8ed1e16cb45d51fa89591418a5410bac;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=58ed33749571dde2078dd3bc28538bbc49be430c;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c index 58ed33749..239e108b8 100644 --- a/drivers/sbus/char/openprom.c +++ b/drivers/sbus/char/openprom.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -391,13 +392,16 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file, return -ENOMEM; } - prom_getproperty(op.op_nodeid, str, tmp, len); - - tmp[len] = '\0'; + cnt = prom_getproperty(op.op_nodeid, str, tmp, len); + if (cnt <= 0) { + error = -EINVAL; + } else { + tmp[len] = '\0'; - if (__copy_to_user(argp, &op, sizeof(op)) != 0 - || copy_to_user(op.op_buf, tmp, len) != 0) - error = -EFAULT; + if (__copy_to_user(argp, &op, sizeof(op)) != 0 || + copy_to_user(op.op_buf, tmp, len) != 0) + error = -EFAULT; + } kfree(tmp); kfree(str); @@ -565,6 +569,40 @@ static int openprom_ioctl(struct inode * inode, struct file * file, } } +static long openprom_compat_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) +{ + long rval = -ENOTTY; + + /* + * SunOS/Solaris only, the NetBSD one's have embedded pointers in + * the arg which we'd need to clean up... + */ + switch (cmd) { + case OPROMGETOPT: + case OPROMSETOPT: + case OPROMNXTOPT: + case OPROMSETOPT2: + case OPROMNEXT: + case OPROMCHILD: + case OPROMGETPROP: + case OPROMNXTPROP: + case OPROMU2P: + case OPROMGETCONS: + case OPROMGETFBNAME: + case OPROMGETBOOTARGS: + case OPROMSETCUR: + case OPROMPCI2NODE: + case OPROMPATH2NODE: + lock_kernel(); + rval = openprom_ioctl(file->f_dentry->d_inode, file, cmd, arg); + lock_kernel(); + break; + } + + return rval; +} + static int openprom_open(struct inode * inode, struct file * file) { DATA *data; @@ -590,6 +628,7 @@ static struct file_operations openprom_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .ioctl = openprom_ioctl, + .compat_ioctl = openprom_compat_ioctl, .open = openprom_open, .release = openprom_release, };