2018-03-21 16:50:10

by Pierre-Yves MORDRET

[permalink] [raw]
Subject: [PATCH v2] i2c: i2c-stm32f7: fix no check on returned setup

Before assigning returned setup structure check if not null

Fixes: 463a9215f3ca7600b5ff ("i2c: stm32f7: fix setup structure")
Signed-off-by: Pierre-Yves MORDRET <[email protected]>
---
Version history:
v1:
* Initial
v2:
* fill "ret" with error statement before go to "clk_free"
---
---
drivers/i2c/busses/i2c-stm32f7.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index b445b3b..f273e28 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -888,6 +888,11 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
}

setup = of_device_get_match_data(&pdev->dev);
+ if (!setup) {
+ dev_err(&pdev->dev, "Can't get device data\n");
+ ret = -ENODEV;
+ goto clk_free;
+ }
i2c_dev->setup = *setup;

ret = device_property_read_u32(i2c_dev->dev, "i2c-scl-rising-time-ns",
--
2.7.4



2018-03-22 08:35:16

by Alexandre Torgue

[permalink] [raw]
Subject: Re: [PATCH v2] i2c: i2c-stm32f7: fix no check on returned setup



On 03/21/2018 05:48 PM, Pierre-Yves MORDRET wrote:
> Before assigning returned setup structure check if not null
>
> Fixes: 463a9215f3ca7600b5ff ("i2c: stm32f7: fix setup structure")
> Signed-off-by: Pierre-Yves MORDRET <[email protected]>
> ---
> Version history:
> v1:
> * Initial
> v2:
> * fill "ret" with error statement before go to "clk_free"
> ---
> ---
> drivers/i2c/busses/i2c-stm32f7.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
> index b445b3b..f273e28 100644
> --- a/drivers/i2c/busses/i2c-stm32f7.c
> +++ b/drivers/i2c/busses/i2c-stm32f7.c
> @@ -888,6 +888,11 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
> }
>
> setup = of_device_get_match_data(&pdev->dev);
> + if (!setup) {
> + dev_err(&pdev->dev, "Can't get device data\n");
> + ret = -ENODEV;
> + goto clk_free;
> + }
> i2c_dev->setup = *setup;
>
> ret = device_property_read_u32(i2c_dev->dev, "i2c-scl-rising-time-ns",
>
Acked-by: Alexandre TORGUE <[email protected]>

2018-03-24 12:39:31

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH v2] i2c: i2c-stm32f7: fix no check on returned setup

On Wed, Mar 21, 2018 at 05:48:40PM +0100, Pierre-Yves MORDRET wrote:
> Before assigning returned setup structure check if not null
>
> Fixes: 463a9215f3ca7600b5ff ("i2c: stm32f7: fix setup structure")
> Signed-off-by: Pierre-Yves MORDRET <[email protected]>

Applied to for-current, thanks!


Attachments:
(No filename) (310.00 B)
signature.asc (849.00 B)
Download all attachments