aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/raw1394.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ieee1394/raw1394.c')
-rw-r--r--drivers/ieee1394/raw1394.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index f7de546f2ed6..20ce539580f1 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -408,34 +408,34 @@ static void fcp_request(struct hpsb_host *host, int nodeid, int direction,
408 408
409#ifdef CONFIG_COMPAT 409#ifdef CONFIG_COMPAT
410struct compat_raw1394_req { 410struct compat_raw1394_req {
411 __u32 type; 411 __u32 type;
412 __s32 error; 412 __s32 error;
413 __u32 misc; 413 __u32 misc;
414 414
415 __u32 generation; 415 __u32 generation;
416 __u32 length; 416 __u32 length;
417 417
418 __u64 address; 418 __u64 address;
419 419
420 __u64 tag; 420 __u64 tag;
421 421
422 __u64 sendb; 422 __u64 sendb;
423 __u64 recvb; 423 __u64 recvb;
424} __attribute__((packed)); 424} __attribute__((packed));
425 425
426static const char __user *raw1394_compat_write(const char __user *buf) 426static const char __user *raw1394_compat_write(const char __user *buf)
427{ 427{
428 struct compat_raw1394_req __user *cr = (typeof(cr)) buf; 428 struct compat_raw1394_req __user *cr = (typeof(cr)) buf;
429 struct raw1394_request __user *r; 429 struct raw1394_request __user *r;
430 r = compat_alloc_user_space(sizeof(struct raw1394_request)); 430 r = compat_alloc_user_space(sizeof(struct raw1394_request));
431 431
432#define C(x) __copy_in_user(&r->x, &cr->x, sizeof(r->x)) 432#define C(x) __copy_in_user(&r->x, &cr->x, sizeof(r->x))
433 433
434 if (copy_in_user(r, cr, sizeof(struct compat_raw1394_req)) || 434 if (copy_in_user(r, cr, sizeof(struct compat_raw1394_req)) ||
435 C(address) || 435 C(address) ||
436 C(tag) || 436 C(tag) ||
437 C(sendb) || 437 C(sendb) ||
438 C(recvb)) 438 C(recvb))
439 return ERR_PTR(-EFAULT); 439 return ERR_PTR(-EFAULT);
440 return (const char __user *)r; 440 return (const char __user *)r;
441} 441}
@@ -443,11 +443,11 @@ static const char __user *raw1394_compat_write(const char __user *buf)
443 443
444#define P(x) __put_user(r->x, &cr->x) 444#define P(x) __put_user(r->x, &cr->x)
445 445
446static int 446static int
447raw1394_compat_read(const char __user *buf, struct raw1394_request *r) 447raw1394_compat_read(const char __user *buf, struct raw1394_request *r)
448{ 448{
449 struct compat_raw1394_req __user *cr = (typeof(cr)) r; 449 struct compat_raw1394_req __user *cr = (typeof(cr)) r;
450 if (!access_ok(VERIFY_WRITE,cr,sizeof(struct compat_raw1394_req)) || 450 if (!access_ok(VERIFY_WRITE, cr, sizeof(struct compat_raw1394_req)) ||
451 P(type) || 451 P(type) ||
452 P(error) || 452 P(error) ||
453 P(misc) || 453 P(misc) ||
@@ -512,18 +512,17 @@ static ssize_t raw1394_read(struct file *file, char __user * buffer,
512 } 512 }
513 513
514#ifdef CONFIG_COMPAT 514#ifdef CONFIG_COMPAT
515 if (count == sizeof(struct compat_raw1394_req) && 515 if (count == sizeof(struct compat_raw1394_req) &&
516 sizeof(struct compat_raw1394_req) != 516 sizeof(struct compat_raw1394_req) !=
517 sizeof(struct raw1394_request)) { 517 sizeof(struct raw1394_request)) {
518 ret = raw1394_compat_read(buffer, &req->req); 518 ret = raw1394_compat_read(buffer, &req->req);
519 519 } else
520 } else
521#endif 520#endif
522 { 521 {
523 if (copy_to_user(buffer, &req->req, sizeof(req->req))) { 522 if (copy_to_user(buffer, &req->req, sizeof(req->req))) {
524 ret = -EFAULT; 523 ret = -EFAULT;
525 goto out; 524 goto out;
526 } 525 }
527 ret = (ssize_t) sizeof(struct raw1394_request); 526 ret = (ssize_t) sizeof(struct raw1394_request);
528 } 527 }
529 out: 528 out:
@@ -2348,7 +2347,6 @@ static int state_connected(struct file_info *fi, struct pending_request *req)
2348 return handle_async_request(fi, req, node); 2347 return handle_async_request(fi, req, node);
2349} 2348}
2350 2349
2351
2352static ssize_t raw1394_write(struct file *file, const char __user * buffer, 2350static ssize_t raw1394_write(struct file *file, const char __user * buffer,
2353 size_t count, loff_t * offset_is_ignored) 2351 size_t count, loff_t * offset_is_ignored)
2354{ 2352{
@@ -2357,9 +2355,9 @@ static ssize_t raw1394_write(struct file *file, const char __user * buffer,
2357 ssize_t retval = 0; 2355 ssize_t retval = 0;
2358 2356
2359#ifdef CONFIG_COMPAT 2357#ifdef CONFIG_COMPAT
2360 if (count == sizeof(struct compat_raw1394_req) && 2358 if (count == sizeof(struct compat_raw1394_req) &&
2361 sizeof(struct compat_raw1394_req) != 2359 sizeof(struct compat_raw1394_req) !=
2362 sizeof(struct raw1394_request)) { 2360 sizeof(struct raw1394_request)) {
2363 buffer = raw1394_compat_write(buffer); 2361 buffer = raw1394_compat_write(buffer);
2364 if (IS_ERR(buffer)) 2362 if (IS_ERR(buffer))
2365 return PTR_ERR(buffer); 2363 return PTR_ERR(buffer);