Commit 73d58588 authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Linus Torvalds

[PATCH] pcmcia Oopses fixes

Fix some NULL dereferences in the pcmcia code when using old userland
tools.
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 94585136
...@@ -426,7 +426,7 @@ static int ds_open(struct inode *inode, struct file *file) ...@@ -426,7 +426,7 @@ static int ds_open(struct inode *inode, struct file *file)
if (!warning_printed) { if (!warning_printed) {
printk(KERN_INFO "pcmcia: Detected deprecated PCMCIA ioctl " printk(KERN_INFO "pcmcia: Detected deprecated PCMCIA ioctl "
"usage.\n"); "usage from process: %s.\n", current->comm);
printk(KERN_INFO "pcmcia: This interface will soon be removed from " printk(KERN_INFO "pcmcia: This interface will soon be removed from "
"the kernel; please expect breakage unless you upgrade " "the kernel; please expect breakage unless you upgrade "
"to new tools.\n"); "to new tools.\n");
...@@ -601,8 +601,12 @@ static int ds_ioctl(struct inode * inode, struct file * file, ...@@ -601,8 +601,12 @@ static int ds_ioctl(struct inode * inode, struct file * file,
ret = CS_BAD_ARGS; ret = CS_BAD_ARGS;
else { else {
struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function); struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function);
ret = pccard_get_configuration_info(s, p_dev, &buf->config); if (p_dev == NULL)
pcmcia_put_dev(p_dev); ret = CS_BAD_ARGS;
else {
ret = pccard_get_configuration_info(s, p_dev, &buf->config);
pcmcia_put_dev(p_dev);
}
} }
break; break;
case DS_GET_FIRST_TUPLE: case DS_GET_FIRST_TUPLE:
...@@ -632,8 +636,12 @@ static int ds_ioctl(struct inode * inode, struct file * file, ...@@ -632,8 +636,12 @@ static int ds_ioctl(struct inode * inode, struct file * file,
ret = CS_BAD_ARGS; ret = CS_BAD_ARGS;
else { else {
struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function); struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function);
ret = pccard_get_status(s, p_dev, &buf->status); if (p_dev == NULL)
pcmcia_put_dev(p_dev); ret = CS_BAD_ARGS;
else {
ret = pccard_get_status(s, p_dev, &buf->status);
pcmcia_put_dev(p_dev);
}
} }
break; break;
case DS_VALIDATE_CIS: case DS_VALIDATE_CIS:
...@@ -665,9 +673,10 @@ static int ds_ioctl(struct inode * inode, struct file * file, ...@@ -665,9 +673,10 @@ static int ds_ioctl(struct inode * inode, struct file * file,
if (!(buf->conf_reg.Function && if (!(buf->conf_reg.Function &&
(buf->conf_reg.Function >= s->functions))) { (buf->conf_reg.Function >= s->functions))) {
struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->conf_reg.Function); struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->conf_reg.Function);
if (p_dev) if (p_dev) {
ret = pcmcia_access_configuration_register(p_dev, &buf->conf_reg); ret = pcmcia_access_configuration_register(p_dev, &buf->conf_reg);
pcmcia_put_dev(p_dev); pcmcia_put_dev(p_dev);
}
} }
break; break;
case DS_GET_FIRST_REGION: case DS_GET_FIRST_REGION:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment