diff options
author | Dan Carpenter <error27@gmail.com> | 2010-05-04 08:14:29 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-19 11:59:05 -0400 |
commit | 32ec4576c3fb37316b1d11a04b220527822f3f0d (patch) | |
tree | b6e8d8e6574cca08c6f19e29bcaca6b8af1aa830 /drivers/media/dvb | |
parent | 9723dbb034e45775037c5dd098652e1628a1c9ef (diff) |
V4L/DVB: media/az6027: doing dma on the stack
I changed the dma buffers to use allocated memory instead of stack
memory.
The reason for this is documented in Documentation/DMA-API-HOWTO.txt
under the section: "What memory is DMA'able?" That document was only
added a couple weeks ago and there are still lots of modules which
haven't been corrected yet. Btw. Smatch includes a pretty good test to
find places which use stack memory as a dma buffer. That's how I found
these. (http://smatch.sf.net).
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/dvb-usb/az6027.c | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/drivers/media/dvb/dvb-usb/az6027.c b/drivers/media/dvb/dvb-usb/az6027.c index 8934788bd83b..baaa301c5768 100644 --- a/drivers/media/dvb/dvb-usb/az6027.c +++ b/drivers/media/dvb/dvb-usb/az6027.c | |||
@@ -417,11 +417,15 @@ static int az6027_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, | |||
417 | u16 value; | 417 | u16 value; |
418 | u16 index; | 418 | u16 index; |
419 | int blen; | 419 | int blen; |
420 | u8 b[12]; | 420 | u8 *b; |
421 | 421 | ||
422 | if (slot != 0) | 422 | if (slot != 0) |
423 | return -EINVAL; | 423 | return -EINVAL; |
424 | 424 | ||
425 | b = kmalloc(12, GFP_KERNEL); | ||
426 | if (!b) | ||
427 | return -ENOMEM; | ||
428 | |||
425 | mutex_lock(&state->ca_mutex); | 429 | mutex_lock(&state->ca_mutex); |
426 | 430 | ||
427 | req = 0xC1; | 431 | req = 0xC1; |
@@ -438,6 +442,7 @@ static int az6027_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, | |||
438 | } | 442 | } |
439 | 443 | ||
440 | mutex_unlock(&state->ca_mutex); | 444 | mutex_unlock(&state->ca_mutex); |
445 | kfree(b); | ||
441 | return ret; | 446 | return ret; |
442 | } | 447 | } |
443 | 448 | ||
@@ -485,11 +490,15 @@ static int az6027_ci_read_cam_control(struct dvb_ca_en50221 *ca, | |||
485 | u16 value; | 490 | u16 value; |
486 | u16 index; | 491 | u16 index; |
487 | int blen; | 492 | int blen; |
488 | u8 b[12]; | 493 | u8 *b; |
489 | 494 | ||
490 | if (slot != 0) | 495 | if (slot != 0) |
491 | return -EINVAL; | 496 | return -EINVAL; |
492 | 497 | ||
498 | b = kmalloc(12, GFP_KERNEL); | ||
499 | if (!b) | ||
500 | return -ENOMEM; | ||
501 | |||
493 | mutex_lock(&state->ca_mutex); | 502 | mutex_lock(&state->ca_mutex); |
494 | 503 | ||
495 | req = 0xC3; | 504 | req = 0xC3; |
@@ -510,6 +519,7 @@ static int az6027_ci_read_cam_control(struct dvb_ca_en50221 *ca, | |||
510 | } | 519 | } |
511 | 520 | ||
512 | mutex_unlock(&state->ca_mutex); | 521 | mutex_unlock(&state->ca_mutex); |
522 | kfree(b); | ||
513 | return ret; | 523 | return ret; |
514 | } | 524 | } |
515 | 525 | ||
@@ -556,7 +566,11 @@ static int CI_CamReady(struct dvb_ca_en50221 *ca, int slot) | |||
556 | u16 value; | 566 | u16 value; |
557 | u16 index; | 567 | u16 index; |
558 | int blen; | 568 | int blen; |
559 | u8 b[12]; | 569 | u8 *b; |
570 | |||
571 | b = kmalloc(12, GFP_KERNEL); | ||
572 | if (!b) | ||
573 | return -ENOMEM; | ||
560 | 574 | ||
561 | req = 0xC8; | 575 | req = 0xC8; |
562 | value = 0; | 576 | value = 0; |
@@ -570,6 +584,7 @@ static int CI_CamReady(struct dvb_ca_en50221 *ca, int slot) | |||
570 | } else{ | 584 | } else{ |
571 | ret = b[0]; | 585 | ret = b[0]; |
572 | } | 586 | } |
587 | kfree(b); | ||
573 | return ret; | 588 | return ret; |
574 | } | 589 | } |
575 | 590 | ||
@@ -667,8 +682,11 @@ static int az6027_ci_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int o | |||
667 | u16 value; | 682 | u16 value; |
668 | u16 index; | 683 | u16 index; |
669 | int blen; | 684 | int blen; |
670 | u8 b[12]; | 685 | u8 *b; |
671 | 686 | ||
687 | b = kmalloc(12, GFP_KERNEL); | ||
688 | if (!b) | ||
689 | return -ENOMEM; | ||
672 | mutex_lock(&state->ca_mutex); | 690 | mutex_lock(&state->ca_mutex); |
673 | 691 | ||
674 | req = 0xC5; | 692 | req = 0xC5; |
@@ -692,6 +710,7 @@ static int az6027_ci_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int o | |||
692 | } | 710 | } |
693 | 711 | ||
694 | mutex_unlock(&state->ca_mutex); | 712 | mutex_unlock(&state->ca_mutex); |
713 | kfree(b); | ||
695 | return ret; | 714 | return ret; |
696 | } | 715 | } |
697 | 716 | ||
@@ -943,10 +962,16 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n | |||
943 | u16 value; | 962 | u16 value; |
944 | int length; | 963 | int length; |
945 | u8 req; | 964 | u8 req; |
946 | u8 data[256]; | 965 | u8 *data; |
966 | |||
967 | data = kmalloc(256, GFP_KERNEL); | ||
968 | if (!data) | ||
969 | return -ENOMEM; | ||
947 | 970 | ||
948 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) | 971 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) { |
972 | kfree(data); | ||
949 | return -EAGAIN; | 973 | return -EAGAIN; |
974 | } | ||
950 | 975 | ||
951 | if (num > 2) | 976 | if (num > 2) |
952 | warn("more than 2 i2c messages at a time is not handled yet. TODO."); | 977 | warn("more than 2 i2c messages at a time is not handled yet. TODO."); |
@@ -1016,6 +1041,7 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n | |||
1016 | } | 1041 | } |
1017 | } | 1042 | } |
1018 | mutex_unlock(&d->i2c_mutex); | 1043 | mutex_unlock(&d->i2c_mutex); |
1044 | kfree(data); | ||
1019 | 1045 | ||
1020 | return i; | 1046 | return i; |
1021 | } | 1047 | } |
@@ -1036,8 +1062,14 @@ int az6027_identify_state(struct usb_device *udev, | |||
1036 | struct dvb_usb_device_description **desc, | 1062 | struct dvb_usb_device_description **desc, |
1037 | int *cold) | 1063 | int *cold) |
1038 | { | 1064 | { |
1039 | u8 b[16]; | 1065 | u8 *b; |
1040 | s16 ret = usb_control_msg(udev, | 1066 | s16 ret; |
1067 | |||
1068 | b = kmalloc(16, GFP_KERNEL); | ||
1069 | if (!b) | ||
1070 | return -ENOMEM; | ||
1071 | |||
1072 | ret = usb_control_msg(udev, | ||
1041 | usb_rcvctrlpipe(udev, 0), | 1073 | usb_rcvctrlpipe(udev, 0), |
1042 | 0xb7, | 1074 | 0xb7, |
1043 | USB_TYPE_VENDOR | USB_DIR_IN, | 1075 | USB_TYPE_VENDOR | USB_DIR_IN, |
@@ -1048,7 +1080,7 @@ int az6027_identify_state(struct usb_device *udev, | |||
1048 | USB_CTRL_GET_TIMEOUT); | 1080 | USB_CTRL_GET_TIMEOUT); |
1049 | 1081 | ||
1050 | *cold = ret <= 0; | 1082 | *cold = ret <= 0; |
1051 | 1083 | kfree(b); | |
1052 | deb_info("cold: %d\n", *cold); | 1084 | deb_info("cold: %d\n", *cold); |
1053 | return 0; | 1085 | return 0; |
1054 | } | 1086 | } |