ANDROID: fix uninitilized variable

Currently we set CONFIG_CC_OPTIMIZE_FOR_SIZE which suppressed the compiler
warning of unused variables which can lead undefined behavior e.g. memory
corruption and panic. See https://lkml.org/lkml/2013/3/25/347.

This patch fixes all the uninitilized variables in kernel

Bug: 33353384
Test: On device
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I0ae1082f447b435d71156d471878ba71aa16c378
This commit is contained in:
Wei Wang 2016-12-12 15:31:49 -08:00 committed by syphyr
parent dce0df919e
commit bb454f3bae
11 changed files with 26 additions and 21 deletions

View File

@ -987,6 +987,8 @@ void sanity_check_clock_tree(u32 muxval, struct mux_clk *mux)
case AUX_CLK_SEL:
rate = sys_apcsaux_clk.c.rate;
break;
default:
return;
};
break;
case PLL0_EARLY_SEL:
@ -997,6 +999,8 @@ void sanity_check_clock_tree(u32 muxval, struct mux_clk *mux)
rate = readl_relaxed(base + C0_PLLA_L_VAL);
rate *= xo_ao.c.rate;
break;
default:
return;
};
/* One regulator */
@ -1556,7 +1560,7 @@ static void populate_opp_table(struct platform_device *pdev)
struct platform_device *apc0_dev, *apc1_dev;
struct device_node *apc0_node, *apc1_node;
unsigned long apc0_fmax, apc1_fmax;
int cpu, a53_cpu, a57_cpu;
int cpu, a53_cpu = 0, a57_cpu = 0;
apc0_node = of_parse_phandle(pdev->dev.of_node, "vdd-a53-supply", 0);
apc1_node = of_parse_phandle(pdev->dev.of_node, "vdd-a57-supply", 0);
@ -1957,7 +1961,6 @@ static int cpu_clock_8994_driver_probe(struct platform_device *pdev)
u64 pte_efuse;
char a57speedbinstr[] = "qcom,a57-speedbinXX-vXX";
char a53speedbinstr[] = "qcom,a53-speedbinXX-vXX";
v2 = msm8994_v2 | msm8992;
a53_pll0_main.c.flags = CLKFLAG_NO_RATE_CACHE;
@ -1984,7 +1987,7 @@ static int cpu_clock_8994_driver_probe(struct platform_device *pdev)
snprintf(a53speedbinstr, ARRAY_SIZE(a53speedbinstr),
"qcom,a53-speedbin%d-v%d", a53speedbin, pvs_ver);
} else if (v2)
} else
pte_efuse = readl_relaxed(vbases[EFUSE_BASE]);
snprintf(a53speedbinstr, ARRAY_SIZE(a53speedbinstr),

View File

@ -586,7 +586,7 @@ static void cpufreq_allstats_create(unsigned int cpu,
static int cpufreq_stat_notifier_policy(struct notifier_block *nb,
unsigned long val, void *data)
{
int ret, count = 0, i;
int ret = 0, count = 0, i;
struct cpufreq_policy *policy = data;
struct cpufreq_frequency_table *table;
unsigned int cpu_num, cpu = policy->cpu;

View File

@ -2384,7 +2384,7 @@ static int synaptics_rmi4_fwu_init(struct synaptics_rmi4_data *rmi4_data)
fwu->ts_info = kzalloc(RMI4_INFO_MAX_LEN, GFP_KERNEL);
if (!fwu->ts_info) {
dev_err(&rmi4_data->i2c_client->dev, "Not enough memory\n");
goto exit_free_ts_info;
goto exit_free_mem;
}
synaptics_rmi4_update_debug_info();
@ -2398,7 +2398,6 @@ static int synaptics_rmi4_fwu_init(struct synaptics_rmi4_data *rmi4_data)
#endif
return 0;
exit_free_ts_info:
debugfs_remove(temp);
exit_remove_attrs:
for (attr_count--; attr_count >= 0; attr_count--) {

View File

@ -290,7 +290,7 @@ int msm_core_debug_init(void)
msm_core_data = get_cpu_pwr_stats();
if (!msm_core_data)
goto fail;
return PTR_ERR(NULL);
dir = debugfs_create_dir("msm_core", NULL);
if (IS_ERR_OR_NULL(dir))

View File

@ -347,10 +347,10 @@ static int update_userspace_power(struct sched_params __user *argp)
{
int i;
int ret;
int cpu;
struct cpu_activity_info *node;
struct cpu_static_info *sp, *clear_sp;
int cpumask, cluster, mpidr;
int cpu = num_possible_cpus();
get_user(cpumask, &argp->cpumask);
get_user(cluster, &argp->cluster);

View File

@ -2449,9 +2449,7 @@ static int estimate_battery_age(struct fg_chip *chip, int *actual_capacity)
}
battery_soc = get_battery_soc_raw(chip) * 100 / FULL_PERCENT_3B;
if (rc) {
goto error_done;
} else if (battery_soc < 25 || battery_soc > 75) {
if (battery_soc < 25 || battery_soc > 75) {
if (fg_debug_mask & FG_AGING)
pr_info("Battery SoC (%d) out of range, aborting\n",
(int)battery_soc);
@ -4401,6 +4399,7 @@ static int fg_batt_profile_init(struct fg_chip *chip)
const char *data, *batt_type_str, *old_batt_type;
bool tried_again = false, vbat_in_range, profiles_same;
u8 reg = 0;
old_batt_type = default_batt_type;
wait:
fg_stay_awake(&chip->profile_wakeup_source);
@ -4428,7 +4427,6 @@ wait:
fg_batt_type);
if (!profile_node) {
pr_err("couldn't find profile handle\n");
old_batt_type = default_batt_type;
rc = -ENODATA;
goto fail;
}
@ -5912,7 +5910,6 @@ static int fg_hw_init(struct fg_chip *chip)
static int fg_setup_memif_offset(struct fg_chip *chip)
{
int rc;
u8 dig_major;
rc = fg_read(chip, chip->revision, chip->mem_base + DIG_MINOR, 4);
if (rc) {
@ -5930,7 +5927,7 @@ static int fg_setup_memif_offset(struct fg_chip *chip)
chip->ima_supported = true;
break;
default:
pr_err("Digital Major rev=%d not supported\n", dig_major);
pr_err("Digital Major rev=%d not supported\n", chip->revision[DIG_MAJOR]);
return -EINVAL;
}

View File

@ -7592,6 +7592,8 @@ static int smbchg_probe(struct spmi_device *spmi)
rc);
return rc;
}
} else {
vadc_dev = NULL;
}
if (of_find_property(spmi->dev.of_node, "qcom,vchg_sns-vadc", NULL)) {

View File

@ -1700,7 +1700,7 @@ static void smb1351_chg_ctrl_in_jeita(struct smb1351_charger *chip)
static void smb1351_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
{
struct smb1351_charger *chip = ctx;
struct battery_status *cur;
struct battery_status *cur = NULL;
int temp;
if (state >= ADC_TM_STATE_NUM) {
@ -1800,6 +1800,11 @@ static void smb1351_chg_adc_notification(enum qpnp_tm_state state, void *ctx)
}
}
if (!cur) {
pr_err("invalid transaction: state %d, temp %d\n", state, temp);
return;
}
if (cur->batt_present)
chip->battery_missing = false;
else

View File

@ -155,7 +155,7 @@ static int npa_dump_probe(struct platform_device *pdev)
struct resource *res;
void __iomem *npa_base, *rpm_base;
struct dentry *dent;
int ret;
int ret = 0;
/* Get the location of the NPA log's start address offset */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

View File

@ -1666,4 +1666,3 @@ int mdss_mdp_cmd_start(struct mdss_mdp_ctl *ctl)
return 0;
}

View File

@ -4337,10 +4337,10 @@ static int msm_routing_put_stereo_to_custom_stereo_control(
int flag = 0, i = 0, rc = 0, idx = 0;
int be_index = 0, port_id, topo_id;
unsigned int session_id = 0;
uint16_t op_FL_ip_FL_weight;
uint16_t op_FL_ip_FR_weight;
uint16_t op_FR_ip_FL_weight;
uint16_t op_FR_ip_FR_weight;
uint16_t op_FL_ip_FL_weight = 0;
uint16_t op_FL_ip_FR_weight = 0;
uint16_t op_FR_ip_FL_weight = 0;
uint16_t op_FR_ip_FR_weight = 0;
flag = ucontrol->value.integer.value[0];
pr_debug("%s E flag %d\n", __func__, flag);