All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Codrin.Ciubotariu@microchip.com
Cc: alsa-devel@alsa-project.org
Subject: Re: [bug report] ASoC: mchp-spdifrx: add driver for SPDIF RX
Date: Thu, 3 Dec 2020 21:38:23 +0300	[thread overview]
Message-ID: <20201203183823.GQ2789@kadam> (raw)
In-Reply-To: <f58f5379-c645-6a0c-5345-88b72e4492a5@microchip.com>

On Thu, Dec 03, 2020 at 03:31:33PM +0000, Codrin.Ciubotariu@microchip.com wrote:
> On 03.12.2020 16:58, Dan Carpenter wrote:
> > Hello Codrin Ciubotariu,
> > 
> > The patch ef265c55c1ac: "ASoC: mchp-spdifrx: add driver for SPDIF RX"
> > from Oct 2, 2020, leads to the following static checker warning:
> > 
> >          sound/soc/atmel/mchp-spdifrx.c:468 mchp_spdifrx_hw_params()
> >          warn: 'dev->gclk' not released on lines: 468.
> > 
> > sound/soc/atmel/mchp-spdifrx.c
> >     442                          params_format(params));
> >     443                  return -EINVAL;
> >     444          }
> >     445
> >     446          if (dev->gclk_enabled) {
> >     447                  clk_disable_unprepare(dev->gclk);
> >     448                  dev->gclk_enabled = 0;
> >     449          }
> >     450          ret = clk_set_min_rate(dev->gclk, params_rate(params) *
> >     451                                            SPDIFRX_GCLK_RATIO_MIN + 1);
> >     452          if (ret) {
> >     453                  dev_err(dev->dev,
> >     454                          "unable to set gclk min rate: rate %u * ratio %u + 1\n",
> >     455                          params_rate(params), SPDIFRX_GCLK_RATIO_MIN);
> >     456                  return ret;
> >     457          }
> >     458          ret = clk_prepare_enable(dev->gclk);
> >                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > 
> >     459          if (ret) {
> >     460                  dev_err(dev->dev, "unable to enable gclk: %d\n", ret);
> >     461                  return ret;
> >     462          }
> >     463          dev->gclk_enabled = 1;
> >     464
> >     465          dev_dbg(dev->dev, "GCLK range min set to %d\n",
> >     466                  params_rate(params) * SPDIFRX_GCLK_RATIO_MIN + 1);
> >     467
> >     468          return regmap_write(dev->regmap, SPDIFRX_MR, mr);
> >                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > Smatch is complaining that if the regmap_write() fails then we should
> > disable and unprepare the "dev->gclk".
> > 
> >     469  }
> > 
> 
> Thanks for reporting this Dan. hw_free() callback is still called if 
> hw_params() fails, which will unprepare gclk, but I guess it doesn't 
> hurt to add what you suggested.

It might hurt if it leads to a double free...  Just leave it as is.
This is a new warning message for Smatch and I'm still working out the
kinks.

regards,
dan carpenter


      reply	other threads:[~2020-12-03 18:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-03 14:58 [bug report] ASoC: mchp-spdifrx: add driver for SPDIF RX Dan Carpenter
2020-12-03 15:31 ` Codrin.Ciubotariu
2020-12-03 18:38   ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201203183823.GQ2789@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=Codrin.Ciubotariu@microchip.com \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.