Merge: i2c: lpi2c: Avoid calling clk_get_rate during transfer
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4773 JIRA: https://issues.redhat.com/browse/RHEL-48206 CVE: CVE-2024-40965 Signed-off-by: David Arcari <darcari@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: Mark Salter <msalter@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
This commit is contained in:
commit
b6d36557eb
|
@ -100,6 +100,7 @@ struct lpi2c_imx_struct {
|
||||||
__u8 *rx_buf;
|
__u8 *rx_buf;
|
||||||
__u8 *tx_buf;
|
__u8 *tx_buf;
|
||||||
struct completion complete;
|
struct completion complete;
|
||||||
|
unsigned long rate_per;
|
||||||
unsigned int msglen;
|
unsigned int msglen;
|
||||||
unsigned int delivered;
|
unsigned int delivered;
|
||||||
unsigned int block_data;
|
unsigned int block_data;
|
||||||
|
@ -208,7 +209,8 @@ static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx)
|
||||||
|
|
||||||
lpi2c_imx_set_mode(lpi2c_imx);
|
lpi2c_imx_set_mode(lpi2c_imx);
|
||||||
|
|
||||||
clk_rate = clk_get_rate(lpi2c_imx->clks[0].clk);
|
clk_rate = lpi2c_imx->rate_per;
|
||||||
|
|
||||||
if (lpi2c_imx->mode == HS || lpi2c_imx->mode == ULTRA_FAST)
|
if (lpi2c_imx->mode == HS || lpi2c_imx->mode == ULTRA_FAST)
|
||||||
filt = 0;
|
filt = 0;
|
||||||
else
|
else
|
||||||
|
@ -594,6 +596,20 @@ static int lpi2c_imx_probe(struct platform_device *pdev)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lock the parent clock rate to avoid getting parent clock upon
|
||||||
|
* each transfer
|
||||||
|
*/
|
||||||
|
ret = devm_clk_rate_exclusive_get(&pdev->dev, lpi2c_imx->clks[0].clk);
|
||||||
|
if (ret)
|
||||||
|
return dev_err_probe(&pdev->dev, ret,
|
||||||
|
"can't lock I2C peripheral clock rate\n");
|
||||||
|
|
||||||
|
lpi2c_imx->rate_per = clk_get_rate(lpi2c_imx->clks[0].clk);
|
||||||
|
if (!lpi2c_imx->rate_per)
|
||||||
|
return dev_err_probe(&pdev->dev, -EINVAL,
|
||||||
|
"can't get I2C peripheral clock rate\n");
|
||||||
|
|
||||||
pm_runtime_set_autosuspend_delay(&pdev->dev, I2C_PM_TIMEOUT);
|
pm_runtime_set_autosuspend_delay(&pdev->dev, I2C_PM_TIMEOUT);
|
||||||
pm_runtime_use_autosuspend(&pdev->dev);
|
pm_runtime_use_autosuspend(&pdev->dev);
|
||||||
pm_runtime_get_noresume(&pdev->dev);
|
pm_runtime_get_noresume(&pdev->dev);
|
||||||
|
|
Loading…
Reference in New Issue