soc: qcom: Add check devm_kasprintf() returned value
Subsystems (4)
Sasha Levin
maintainerPATCH 1/5 soc: qcom: Add check devm_kasprintf() returned value
From: Charles Han <[email protected]>
[ Upstream commit e694d2b5c58ba2d1e995d068707c8d966e7f5f2a ]
devm_kasprintf() can return a NULL pointer on failure but this returned value in qcom_socinfo_probe() is not checked.
--- drivers/soc/qcom/socinfo.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/soc/qcom/socinfo.c +7 -1
@@ -433,10 +433,16 @@ static int qcom_socinfo_probe(struct platform_device *pdev) qs->attr.revision =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"%u.%u" ,SOCINFO_MAJOR (le32_to_cpu (info->ver)),SOCINFO_MINOR (le32_to_cpu (info->ver))); -if (offsetof(struct socinfo , serial_num) <= item_size) +if (!qs->attr.soc_id || qs->attr.revision) +return -ENOMEM ; + +if (offsetof(struct socinfo , serial_num) <= item_size) { qs->attr.serial_number =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"%u" ,le32_to_cpu (info->serial_num)); +if (!qs->attr.serial_number) +return -ENOMEM ; + } qs->soc_dev =soc_device_register (&qs->attr);if (IS_ERR (qs->soc_dev))
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/5 regulator: rk808: Add apply_bit for BUCK3 on RK809
From: Mikhail Rudenko <[email protected]>
[ Upstream commit 5e53e4a66bc7430dd2d11c18a86410e3a38d2940 ]
Currently, RK809's BUCK3 regulator is modelled in the driver as a configurable regulator with 0.5-2.4V voltage range. But the voltage setting is not actually applied, because when bit 6 of PMIC_POWER_CONFIG register is set to 0 (default), BUCK3 output voltage is determined by the external feedback resistor. Fix this, by setting bit 6 when voltage selection is set. Existing users which do not specify voltage constraints in their device trees will not be affected by this change, since no voltage setting is applied in those cases, and bit 6 is not enabled.
--- drivers/regulator/rk808-regulator.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/regulator/rk808-regulator.c +2 -0
@@ -959,6 +959,8 @@ static const struct regulator_desc rk809_reg[] = { .n_linear_ranges = ARRAY_SIZE(rk817_buck1_voltage_ranges), .vsel_reg = RK817_BUCK3_ON_VSEL_REG, .vsel_mask = RK817_BUCK_VSEL_MASK, + .apply_reg = RK817_POWER_CONFIG, + .apply_bit = RK817_BUCK3_FB_RES_INTER, .enable_reg = RK817_POWER_EN_REG(0), .enable_mask = ENABLE_MASK(RK817_ID_DCDC3), .enable_val = ENABLE_MASK(RK817_ID_DCDC3),
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/5 ASoC: stm: Prevent potential division by zero in stm32_sai_mclk_round_rate()
In reply to Sasha LevinFrom: Luo Yifan <[email protected]>
[ Upstream commit 63c1c87993e0e5bb11bced3d8224446a2bc62338 ]
This patch checks if div is less than or equal to zero (div <= 0). If div is zero or negative, the function returns -EINVAL, ensuring the division operation (*prate / div) is safe to perform.
--- sound/soc/stm/stm32_sai_sub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/stm/stm32_sai_sub.c +2 -2
@@ -379,8 +379,8 @@ static long stm32_sai_mclk_round_rate(struct clk_hw *hw, unsigned long rate,int div; div =stm32_sai_get_clk_div (sai, *prate, rate); -if (div <0 ) -return div; +if (div <=0 ) +return -EINVAL ; mclk->freq = *prate / div;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/5 ASoC: stm: Prevent potential division by zero in stm32_sai_get_clk_div()
In reply to Sasha LevinFrom: Luo Yifan <[email protected]>
[ Upstream commit 23569c8b314925bdb70dd1a7b63cfe6100868315 ]
This patch checks if div is less than or equal to zero (div <= 0). If div is zero or negative, the function returns -EINVAL, ensuring the division operation is safe to perform.
--- sound/soc/stm/stm32_sai_sub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/stm/stm32_sai_sub.c +1 -1
@@ -318,7 +318,7 @@ static int stm32_sai_get_clk_div(struct stm32_sai_sub_data *sai,int div; div =DIV_ROUND_CLOSEST (input_rate, output_rate); -if (div >SAI_XCR1_MCKDIV_MAX (version)) { +if (div >SAI_XCR1_MCKDIV_MAX (version) || div <=0 ) {dev_err (&sai->pdev->dev,"Divider %d out of range\n" , div);return -EINVAL ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/5 proc/softirqs: replace seq_printf with seq_put_decimal_ull_width
In reply to Sasha LevinFrom: David Wang <[email protected]>
[ Upstream commit 84b9749a3a704dcc824a88aa8267247c801d51e4 ]
seq_printf is costy, on a system with n CPUs, reading /proc/softirqs would yield 10*n decimal values, and the extra cost parsing format string grows linearly with number of cpus. Replace seq_printf with seq_put_decimal_ull_width have significant performance improvement. On an 8CPUs system, reading /proc/softirqs show ~40% performance gain with this patch.
--- fs/proc/softirqs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/softirqs.c +1 -1
@@ -19,7 +19,7 @@ static int show_softirqs(struct seq_file *p, void *v)for (i =0 ; i <NR_SOFTIRQS ; i++) {seq_printf (p,"%12s:" , softirq_to_name[i]);for_each_possible_cpu (j) -seq_printf (p," %10u" ,kstat_softirqs_cpu (i, j)); +seq_put_decimal_ull_width (p," " ,kstat_softirqs_cpu (i, j),10 );seq_putc (p,'\n' ); }return 0 ;
Signature · 1 line
2.43.0