patch-2.3.40 linux/drivers/pcmcia/ds.c
Next file: linux/drivers/pcmcia/i82365.c
Previous file: linux/drivers/pcmcia/cs.c
Back to the patch index
Back to the overall index
- Lines: 143
- Date:
Tue Jan 18 22:29:17 2000
- Orig file:
v2.3.39/linux/drivers/pcmcia/ds.c
- Orig date:
Tue Jan 11 22:31:40 2000
diff -u --recursive --new-file v2.3.39/linux/drivers/pcmcia/ds.c linux/drivers/pcmcia/ds.c
@@ -2,7 +2,7 @@
PC Card Driver Services
- ds.c 1.100 1999/11/08 20:47:02
+ ds.c 1.104 2000/01/11 01:18:02
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
@@ -60,11 +60,14 @@
MODULE_PARM(pc_debug, "i");
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
static const char *version =
-"ds.c 1.100 1999/11/08 20:47:02 (David Hinds)";
+"ds.c 1.104 2000/01/11 01:18:02 (David Hinds)";
#else
#define DEBUG(n, args...)
#endif
+MODULE_AUTHOR("David Hinds <dhinds@pcmcia.sourceforge.org>");
+MODULE_DESCRIPTION("PCMCIA Driver Services " CS_RELEASE);
+
/*====================================================================*/
typedef struct driver_info_t {
@@ -155,6 +158,7 @@
break;
if (!driver) {
driver = kmalloc(sizeof(driver_info_t), GFP_KERNEL);
+ if (!driver) return -ENOMEM;
strncpy(driver->dev_info, (char *)dev_info, DEV_NAME_LEN);
driver->use_count = 0;
driver->status = init_status;
@@ -193,7 +197,7 @@
DEV_NAME_LEN) != 0))
d = &(*d)->next;
if (*d == NULL)
- return -1;
+ return -ENODEV;
target = *d;
if (target->use_count == 0) {
@@ -377,6 +381,7 @@
break;
if (driver == NULL) {
driver = kmalloc(sizeof(driver_info_t), GFP_KERNEL);
+ if (!driver) return -ENOMEM;
strncpy(driver->dev_info, bind_info->dev_info, DEV_NAME_LEN);
driver->use_count = 0;
driver->next = root_driver;
@@ -522,11 +527,11 @@
for (d = &root_driver; *d; d = &((*d)->next))
if (c->driver == *d) break;
*d = (*d)->next;
- kfree_s(c->driver, sizeof(driver_info_t));
+ kfree(c->driver);
}
}
*b = c->next;
- kfree_s(c, sizeof(socket_bind_t));
+ kfree(c);
return 0;
} /* unbind_request */
@@ -554,8 +559,9 @@
s->state |= SOCKET_BUSY;
}
- MOD_INC_USE_COUNT;
user = kmalloc(sizeof(user_info_t), GFP_KERNEL);
+ if (!user) return -ENOMEM;
+ MOD_INC_USE_COUNT;
user->event_tail = user->event_head = 0;
user->next = s->user;
user->user_magic = USER_MAGIC;
@@ -593,7 +599,7 @@
return 0;
*link = user->next;
user->user_magic = 0;
- kfree_s(user, sizeof(user_info_t));
+ kfree(user);
MOD_DEC_USE_COUNT;
return 0;
@@ -704,7 +710,7 @@
if (size > sizeof(ds_ioctl_arg_t)) return -EINVAL;
/* Permission check */
- if (!(cmd & IOC_OUT) && !suser())
+ if (!(cmd & IOC_OUT) && !capable(CAP_SYS_ADMIN))
return -EPERM;
if (cmd & IOC_IN) {
@@ -773,7 +779,7 @@
ret = pcmcia_insert_card(s->handle, NULL);
break;
case DS_ACCESS_CONFIGURATION_REGISTER:
- if ((buf.conf_reg.Action == CS_WRITE) && !suser())
+ if ((buf.conf_reg.Action == CS_WRITE) && !capable(CAP_SYS_ADMIN))
return -EPERM;
ret = pcmcia_access_configuration_register(s->handle, &buf.conf_reg);
break;
@@ -798,7 +804,7 @@
ret = pcmcia_replace_cis(s->handle, &buf.cisdump);
break;
case DS_BIND_REQUEST:
- if (!suser()) return -EPERM;
+ if (!capable(CAP_SYS_ADMIN)) return -EPERM;
err = bind_request(i, &buf.bind_info);
break;
case DS_GET_DEVICE_INFO:
@@ -847,17 +853,12 @@
/*====================================================================*/
static struct file_operations ds_fops = {
- NULL, /* lseek */
- ds_read, /* read */
- ds_write, /* write */
- NULL, /* readdir */
- ds_poll, /* poll */
- ds_ioctl, /* ioctl */
- NULL, /* mmap */
- ds_open, /* open */
- NULL, /* flush */
- ds_release, /* release */
- NULL /* fsync */
+ open: ds_open,
+ release: ds_release,
+ ioctl: ds_ioctl,
+ read: ds_read,
+ write: ds_write,
+ poll: ds_poll
};
EXPORT_SYMBOL(register_pccard_driver);
@@ -887,6 +888,7 @@
sockets = serv.Count;
socket_table = kmalloc(sockets*sizeof(socket_info_t), GFP_KERNEL);
+ if (!socket_table) return -1;
for (i = 0, s = socket_table; i < sockets; i++, s++) {
s->state = 0;
s->user = NULL;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)