Merge "radio: iris: Add NULL pointer check"
diff --git a/drivers/media/radio/radio-iris.c b/drivers/media/radio/radio-iris.c
index b6fdeb7..a554749 100644
--- a/drivers/media/radio/radio-iris.c
+++ b/drivers/media/radio/radio-iris.c
@@ -496,8 +496,15 @@
static void iris_q_event(struct iris_device *radio,
enum iris_evt_t event)
{
- struct kfifo *data_b = &radio->data_buf[IRIS_BUF_EVENTS];
+ struct kfifo *data_b;
unsigned char evt = event;
+
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
+
+ data_b = &radio->data_buf[IRIS_BUF_EVENTS];
if (kfifo_in_locked(data_b, &evt, 1, &radio->buf_lock[IRIS_BUF_EVENTS]))
wake_up_interruptible(&radio->event_queue);
}
@@ -582,8 +589,6 @@
skb_queue_head_init(&hdev->cmd_q);
skb_queue_head_init(&hdev->raw_q);
- if (!radio)
- FMDERR(":radio is null");
radio->fm_hdev = hdev;
@@ -674,6 +679,10 @@
struct iris_device *radio = video_get_drvdata(video_get_dev());
__u16 opcode = 0;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ,
HCI_FM_SET_INTERNAL_TONE_GENRATOR);
return radio_hci_send_cmd(hdev, opcode,
@@ -1642,6 +1651,11 @@
__u8 status = *((__u8 *) skb->data);
struct iris_device *radio = video_get_drvdata(video_get_dev());
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
+
if ((radio->mode == FM_TURNING_OFF) && (status == 0)) {
iris_q_event(radio, IRIS_EVT_RADIO_DISABLED);
radio_hci_req_complete(hdev, status);
@@ -1659,6 +1673,10 @@
struct hci_fm_conf_rsp *rsp = (void *)skb->data;
struct iris_device *radio = video_get_drvdata(video_get_dev());
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
if (rsp->status)
return;
@@ -1672,6 +1690,11 @@
struct hci_fm_get_trans_conf_rsp *rsp = (void *)skb->data;
struct iris_device *radio = video_get_drvdata(video_get_dev());
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
+
if (rsp->status)
return;
memcpy((void *)&radio->trans_conf, (void*)&rsp->trans_conf_rsp,
@@ -1685,6 +1708,11 @@
struct hci_fm_conf_rsp *rsp = (void *)skb->data;
struct iris_device *radio = video_get_drvdata(video_get_dev());
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
+
if (rsp->status) {
radio_hci_req_complete(hdev, rsp->status);
return;
@@ -1707,6 +1735,11 @@
struct hci_fm_conf_rsp *rsp = (void *)skb->data;
struct iris_device *radio = video_get_drvdata(video_get_dev());
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
+
if (rsp->status)
return;
@@ -1722,6 +1755,11 @@
struct hci_fm_sig_threshold_rsp *rsp = (void *)skb->data;
struct iris_device *radio = video_get_drvdata(video_get_dev());
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
+
if (rsp->status)
return;
@@ -1733,6 +1771,12 @@
{
struct iris_device *radio = video_get_drvdata(video_get_dev());
struct hci_fm_station_rsp *rsp = (void *)skb->data;
+
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
+
radio->fm_st_rsp = *(rsp);
/* Tune is always succesful */
@@ -1772,9 +1816,16 @@
static void hci_cc_feature_list_rsp(struct radio_hci_dev *hdev,
struct sk_buff *skb)
{
+ struct v4l2_capability *v4l_cap;
struct hci_fm_feature_list_rsp *rsp = (void *)skb->data;
struct iris_device *radio = video_get_drvdata(video_get_dev());
- struct v4l2_capability *v4l_cap = radio->g_cap;
+
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
+
+ v4l_cap = radio->g_cap;
if (rsp->status)
return;
@@ -1789,8 +1840,13 @@
{
struct iris_device *radio = video_get_drvdata(video_get_dev());
struct hci_fm_dbg_param_rsp *rsp = (void *)skb->data;
- radio->st_dbg_param = *(rsp);
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
+
+ radio->st_dbg_param = *(rsp);
if (radio->st_dbg_param.status)
return;
@@ -1800,7 +1856,13 @@
static void iris_q_evt_data(struct iris_device *radio,
char *data, int len, int event)
{
- struct kfifo *data_b = &radio->data_buf[event];
+ struct kfifo *data_b;
+
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
+ data_b = &radio->data_buf[event];
if (kfifo_in_locked(data_b, data, len, &radio->buf_lock[event]))
wake_up_interruptible(&radio->event_queue);
}
@@ -1837,6 +1899,11 @@
__u8 status = *((__u8 *) skb->data);
__u8 len;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
+
if (status)
return;
len = skb->data[1];
@@ -1917,6 +1984,11 @@
{
struct iris_device *radio = video_get_drvdata(video_get_dev());
u8 status = skb->data[0];
+
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
if (status) {
FMDERR("status = %d", status);
return;
@@ -2050,6 +2122,10 @@
int i;
struct iris_device *radio = video_get_drvdata(video_get_dev());
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
memcpy(&radio->fm_st_rsp.station_rsp, &skb->data[0],
sizeof(struct hci_ev_tune_status));
iris_q_event(radio, IRIS_EVT_TUNE_SUCC);
@@ -2092,6 +2168,10 @@
int abs_freq;
int len;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
if (!ev) {
FMDERR("Memory allocation failed");
@@ -2150,6 +2230,10 @@
radio = video_get_drvdata(video_get_dev());
index = RDSGRP_DATA_OFFSET;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return;
+ }
for (blocknum = 0; blocknum < RDS_BLOCKS_NUM; blocknum++) {
temp.rdsBlk[blocknum].rdsLsb =
(skb->data[index]);
@@ -2556,9 +2640,15 @@
static int iris_search(struct iris_device *radio, int on, int dir)
{
int retval = 0;
- enum search_t srch = radio->g_search_mode & SRCH_MODE;
- radio->search_on = on;
+ enum search_t srch;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
+
+ srch = radio->g_search_mode & SRCH_MODE;
+ radio->search_on = on;
if (on) {
switch (srch) {
case SCAN_FOR_STRONG:
@@ -2600,6 +2690,12 @@
int rds_grps_proc = 0x00;
int retval = 0;
+
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
+
if (radio->power_mode != power_mode) {
if (power_mode) {
@@ -2638,6 +2734,12 @@
static int iris_recv_set_region(struct iris_device *radio, int req_region)
{
int retval;
+
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
+
radio->region = req_region;
retval = hci_set_fm_recv_conf(
@@ -2651,6 +2753,11 @@
static int iris_trans_set_region(struct iris_device *radio, int req_region)
{
int retval;
+
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
radio->region = req_region;
retval = hci_set_fm_trans_conf(
@@ -2664,6 +2771,11 @@
{
int retval;
+
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
retval = hci_fm_tune_station(&freq, radio->fm_hdev);
if (retval < 0)
FMDERR("Error while setting the frequency : %d\n", retval);
@@ -2693,6 +2805,11 @@
char cal_mode = 0x00;
int retval = 0x00;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
+
cal_mode = PROCS_CALIB_MODE;
radio->mode = FM_CALIB;
retval = hci_cmd(HCI_FM_ENABLE_RECV_CMD,
@@ -2727,6 +2844,11 @@
struct hci_fm_def_data_rd_req rd;
int lsb, msb;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
+
switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME:
break;
@@ -3012,6 +3134,11 @@
struct iris_device *radio = video_get_drvdata(video_devdata(file));
struct hci_fm_def_data_rd_req default_data_rd;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
+
switch ((ctrl->controls[0]).id) {
case V4L2_CID_PRIVATE_IRIS_READ_DEFAULT:
data = (ctrl->controls[0]).string;
@@ -3041,6 +3168,10 @@
struct iris_device *radio = video_get_drvdata(video_devdata(file));
char *data = NULL;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
switch ((ctrl->controls[0]).id) {
case V4L2_CID_RDS_TX_PS_NAME:
FMDBG("In V4L2_CID_RDS_TX_PS_NAME\n");
@@ -3164,6 +3295,11 @@
char sinr_th, sinr;
__u8 intf_det_low_th, intf_det_high_th, intf_det_out;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
+
switch (ctrl->id) {
case V4L2_CID_PRIVATE_IRIS_TX_TONE:
radio->tone_freq = ctrl->value;
@@ -3846,6 +3982,10 @@
/* Pass the mode of SPUR_CLK */
default_data.mode = CKK_SPUR;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
temp = radio->spur_table_size;
for (cnt = 0; cnt < (temp / 5); cnt++) {
offset = 0;
@@ -3916,6 +4056,10 @@
int retval;
struct iris_device *radio = video_get_drvdata(video_devdata(file));
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
if (tuner->index > 0) {
FMDERR("Invalid Tuner Index");
return -EINVAL;
@@ -3959,6 +4103,12 @@
{
struct iris_device *radio = video_get_drvdata(video_devdata(file));
int retval = 0;
+
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
+
if (tuner->index > 0)
return -EINVAL;
@@ -4010,6 +4160,10 @@
int retval = -1;
freq->frequency = freq->frequency / TUNE_PARAM;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
if (freq->type != V4L2_TUNER_RADIO)
return -EINVAL;
@@ -4137,6 +4291,11 @@
{
struct iris_device *radio;
radio = video_get_drvdata(video_devdata(file));
+
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver));
strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card));
capability->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
@@ -4148,6 +4307,11 @@
{
int retval;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
+
radio->mute_mode.soft_mute = CTRL_ON;
retval = hci_set_fm_mute_mode(&radio->mute_mode,
radio->fm_hdev);
@@ -4185,7 +4349,14 @@
static int initialise_trans(struct iris_device *radio)
{
- int retval = hci_cmd(HCI_FM_GET_TX_CONFIG, radio->fm_hdev);
+ int retval;
+
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
+
+ retval = hci_cmd(HCI_FM_GET_TX_CONFIG, radio->fm_hdev);
if (retval < 0)
FMDERR("get frequency failed %d\n", retval);
@@ -4196,6 +4367,11 @@
{
int retval = 1;
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
+
if (radio->mode == FM_OFF || radio->mode == FM_RECV)
retval = 0;
@@ -4338,6 +4514,10 @@
int i;
struct iris_device *radio = platform_get_drvdata(pdev);
+ if (radio == NULL) {
+ FMDERR(":radio is null");
+ return -EINVAL;
+ }
video_unregister_device(radio->videodev);
for (i = 0; i < IRIS_BUF_MAX; i++)