lkml.org 
[lkml]   [2005]   [Jan]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] USB and Driver Core patches for 2.6.10
Date
From
ChangeSet 1.1938.444.10, 2004/12/17 14:50:58-08:00, greg@kroah.com

[PATCH] AOE: fix up sparse warnings and get rid of a kmalloc in the aoe driver.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


drivers/block/aoe/aoe.h | 2 +-
drivers/block/aoe/aoeblk.c | 4 ++--
drivers/block/aoe/aoechr.c | 28 ++++++----------------------
drivers/block/aoe/aoenet.c | 12 +++++++-----
4 files changed, 16 insertions(+), 30 deletions(-)


diff -Nru a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
--- a/drivers/block/aoe/aoe.h 2005-01-07 15:45:38 -08:00
+++ b/drivers/block/aoe/aoe.h 2005-01-07 15:45:38 -08:00
@@ -158,6 +158,6 @@
void aoenet_exit(void);
void aoenet_xmit(struct sk_buff *);
int is_aoe_netif(struct net_device *ifp);
-int set_aoe_iflist(char *str);
+int set_aoe_iflist(const char __user *str, size_t size);

u64 mac_addr(char addr[6]);
diff -Nru a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
--- a/drivers/block/aoe/aoeblk.c 2005-01-07 15:45:38 -08:00
+++ b/drivers/block/aoe/aoeblk.c 2005-01-07 15:45:38 -08:00
@@ -170,7 +170,7 @@

if (cmd == HDIO_GETGEO) {
d->geo.start = get_start_sect(inode->i_bdev);
- if (!copy_to_user((void *) arg, &d->geo, sizeof d->geo))
+ if (!copy_to_user((void __user *) arg, &d->geo, sizeof d->geo))
return 0;
return -EFAULT;
}
@@ -227,7 +227,7 @@

printk(KERN_INFO "aoe: %012llx e%lu.%lu v%04x has %llu "
"sectors\n", mac_addr(d->addr), d->aoemajor, d->aoeminor,
- d->fw_ver, d->ssize);
+ d->fw_ver, (long long)d->ssize);
}

void __exit
diff -Nru a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
--- a/drivers/block/aoe/aoechr.c 2005-01-07 15:45:38 -08:00
+++ b/drivers/block/aoe/aoechr.c 2005-01-07 15:45:38 -08:00
@@ -51,9 +51,9 @@
}

static int
-interfaces(char *str)
+interfaces(const char __user *str, size_t size)
{
- if (set_aoe_iflist(str)) {
+ if (set_aoe_iflist(str, size)) {
printk(KERN_CRIT
"%s: could not set interface list: %s\n",
__FUNCTION__, "too many interfaces");
@@ -135,24 +135,10 @@
}

static ssize_t
-aoechr_write(struct file *filp, const char *buf, size_t cnt, loff_t *offp)
+aoechr_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offp)
{
- char *str = kcalloc(1, cnt+1, GFP_KERNEL);
- int ret;
+ int ret = -EINVAL;

- if (!str) {
- printk(KERN_CRIT "aoe: aoechr_write: cannot allocate memory\n");
- return -ENOMEM;
- }
-
- ret = -EFAULT;
- if (copy_from_user(str, buf, cnt)) {
- printk(KERN_INFO "aoe: aoechr_write: copy from user failed\n");
- goto out;
- }
-
- str[cnt] = '\0';
- ret = -EINVAL;
switch ((unsigned long) filp->private_data) {
default:
printk(KERN_INFO "aoe: aoechr_write: can't write to that file.\n");
@@ -161,13 +147,11 @@
ret = discover();
break;
case MINOR_INTERFACES:
- ret = interfaces(str);
+ ret = interfaces(buf, cnt);
break;
}
if (ret == 0)
ret = cnt;
- out:
- kfree(str);
return ret;
}

@@ -192,7 +176,7 @@
}

static ssize_t
-aoechr_read(struct file *filp, char *buf, size_t cnt, loff_t *off)
+aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off)
{
int n;
char *mp;
diff -Nru a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
--- a/drivers/block/aoe/aoenet.c 2005-01-07 15:45:38 -08:00
+++ b/drivers/block/aoe/aoenet.c 2005-01-07 15:45:38 -08:00
@@ -53,14 +53,16 @@
}

int
-set_aoe_iflist(char *str)
+set_aoe_iflist(const char __user *user_str, size_t size)
{
- int len = strlen(str);
-
- if (len >= IFLISTSZ)
+ if (size >= IFLISTSZ)
return -EINVAL;

- strcpy(aoe_iflist, str);
+ if (copy_from_user(aoe_iflist, user_str, size)) {
+ printk(KERN_INFO "aoe: %s: copy from user failed\n", __FUNCTION__);
+ return -EFAULT;
+ }
+ aoe_iflist[size] = 0x00;
return 0;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:09    [W:0.138 / U:0.460 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site