diff mbox series

[v4,2/3] rtc: s5m: check the return value of s5m8767_rtc_init_reg()

Message ID 20210111124027.21586-3-brgl@bgdev.pl (mailing list archive)
State Not Applicable
Headers show
Series rtc: s5m: driver improvements | expand

Commit Message

Bartosz Golaszewski Jan. 11, 2021, 12:40 p.m. UTC
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

This function can fail if regmap operations fail so check its return
value in probe().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/rtc/rtc-s5m.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Krzysztof Kozlowski Jan. 11, 2021, 1:35 p.m. UTC | #1
On Mon, Jan 11, 2021 at 01:40:26PM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> This function can fail if regmap operations fail so check its return
> value in probe().
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  drivers/rtc/rtc-s5m.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c
> index eb9dde4095a9..e0011d3cf61b 100644
> --- a/drivers/rtc/rtc-s5m.c
> +++ b/drivers/rtc/rtc-s5m.c
> @@ -791,6 +791,8 @@ static int s5m_rtc_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, info);
>  
>  	ret = s5m8767_rtc_init_reg(info);
> +	if (ret)
> +		return ret;

You leak I2C device.

Best regards,
Krzysztof
Bartosz Golaszewski Jan. 11, 2021, 2:11 p.m. UTC | #2
On Mon, Jan 11, 2021 at 2:35 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Mon, Jan 11, 2021 at 01:40:26PM +0100, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > This function can fail if regmap operations fail so check its return
> > value in probe().
> >
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > ---
> >  drivers/rtc/rtc-s5m.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c
> > index eb9dde4095a9..e0011d3cf61b 100644
> > --- a/drivers/rtc/rtc-s5m.c
> > +++ b/drivers/rtc/rtc-s5m.c
> > @@ -791,6 +791,8 @@ static int s5m_rtc_probe(struct platform_device *pdev)
> >       platform_set_drvdata(pdev, info);
> >
> >       ret = s5m8767_rtc_init_reg(info);
> > +     if (ret)
> > +             return ret;
>
> You leak I2C device.
>

Yes, the next patch fixes it but I changed the order. Actually this
can be moved after 3/3 with no conflicts when applying.

Bartosz
Krzysztof Kozlowski Jan. 11, 2021, 2:12 p.m. UTC | #3
On Mon, Jan 11, 2021 at 03:11:24PM +0100, Bartosz Golaszewski wrote:
> On Mon, Jan 11, 2021 at 2:35 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
> >
> > On Mon, Jan 11, 2021 at 01:40:26PM +0100, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > >
> > > This function can fail if regmap operations fail so check its return
> > > value in probe().
> > >
> > > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > > ---
> > >  drivers/rtc/rtc-s5m.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c
> > > index eb9dde4095a9..e0011d3cf61b 100644
> > > --- a/drivers/rtc/rtc-s5m.c
> > > +++ b/drivers/rtc/rtc-s5m.c
> > > @@ -791,6 +791,8 @@ static int s5m_rtc_probe(struct platform_device *pdev)
> > >       platform_set_drvdata(pdev, info);
> > >
> > >       ret = s5m8767_rtc_init_reg(info);
> > > +     if (ret)
> > > +             return ret;
> >
> > You leak I2C device.
> >
> 
> Yes, the next patch fixes it but I changed the order. Actually this
> can be moved after 3/3 with no conflicts when applying.

Yes, but for bisecting and any backporting (e.g. with autosel) the order
is quite important. Please resend with new order.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c
index eb9dde4095a9..e0011d3cf61b 100644
--- a/drivers/rtc/rtc-s5m.c
+++ b/drivers/rtc/rtc-s5m.c
@@ -791,6 +791,8 @@  static int s5m_rtc_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, info);
 
 	ret = s5m8767_rtc_init_reg(info);
+	if (ret)
+		return ret;
 
 	device_init_wakeup(&pdev->dev, 1);