From: Takashi Iwai <tiwai@suse.de>
To: cujomalainey@chromium.org
Cc: alsa-devel@alsa-project.org, "Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
"Cezary Rojewski" <cezary.rojewski@intel.com>,
"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
"Liam Girdwood" <liam.r.girdwood@linux.intel.com>,
"Peter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
"Bard Liao" <yung-chuan.liao@linux.intel.com>,
"Ranjani Sridharan" <ranjani.sridharan@linux.intel.com>,
"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
"Mark Brown" <broonie@kernel.org>,
"Dan Carpenter" <error27@gmail.com>,
"Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>,
"Clement Lecigne" <clecigne@google.com>,
"Min-Hua Chen" <minhuadotchen@gmail.com>,
"Ivan Orlov" <ivan.orlov0322@gmail.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Thierry Reding" <treding@nvidia.com>,
"Geoff Levand" <geoff@infradead.org>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Kuninori Morimoto" <kuninori.morimoto.gx@renesas.com>
Subject: Re: [PATCH 2/2] ALSA: core: split control primitives out of snd_card
Date: Fri, 25 Aug 2023 12:57:23 +0200 [thread overview]
Message-ID: <87ledz75kc.wl-tiwai@suse.de> (raw)
In-Reply-To: <20230824210339.1126993-3-cujomalainey@chromium.org>
On Thu, 24 Aug 2023 23:02:53 +0200,
cujomalainey@chromium.org wrote:
>
> +struct snd_control
> +{
The open brace should be at the line above.
> + struct device dev; /* control device */
> + struct rw_semaphore controls_rwsem; /* controls lock (list and values) */
> + rwlock_t files_rwlock; /* ctl_files list lock */
> + int controls_count; /* count of all controls */
> + size_t user_ctl_alloc_size; // current memory allocation by user controls.
Better to have the same comment style if we move the whole stuff.
> +int snd_control_new(struct snd_card *card)
....
> +{
> + struct snd_control *ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
> + int err;
> +
> + if (snd_BUG_ON(!card))
> + return -EINVAL;
This may leak the memory allocated in the above.
> + /* the control interface cannot be accessed from the user space until */
> + /* snd_cards_bitmask and snd_cards are set with snd_card_register */
> + err = snd_ctl_create(card);
> + if (err < 0) {
> + dev_err(card->dev, "unable to register control minors\n");
> + kfree(ctl);
> + return err;
This needs a more care. snd_ctl_create() calls put_device() when
snd_device_new() fails, and this already does kfree(). OTOH, the
error path before that point doesn't release the object.
> + }
> + return 0;
> +}
> +EXPORT_SYMBOL(snd_control_new);
This is never called from the driver but only from snd_card_new() &
co, so no need to export.
thanks,
Takashi
next prev parent reply other threads:[~2023-08-25 10:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-24 21:02 [PATCH 0/2][RFC] Refactor snd primitives refcounters cujomalainey
2023-08-24 21:02 ` [PATCH 1/2] ALSA: core: add snd_device_init cujomalainey
2023-08-24 22:23 ` kernel test robot
2023-08-25 10:46 ` Takashi Iwai
2023-08-24 21:02 ` [PATCH 2/2] ALSA: core: split control primitives out of snd_card cujomalainey
2023-08-24 21:15 ` Mark Brown
2023-08-25 10:57 ` Takashi Iwai [this message]
2023-09-03 22:38 ` kernel test robot
2023-08-25 11:15 ` [PATCH 0/2][RFC] Refactor snd primitives refcounters Takashi Iwai
2023-08-25 17:42 ` Curtis Malainey
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=87ledz75kc.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=clecigne@google.com \
--cc=cujomalainey@chromium.org \
--cc=error27@gmail.com \
--cc=geoff@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=ivan.orlov0322@gmail.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=liam.r.girdwood@linux.intel.com \
--cc=maciej.szmigiero@oracle.com \
--cc=minhuadotchen@gmail.com \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=tiwai@suse.com \
--cc=treding@nvidia.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=yung-chuan.liao@linux.intel.com \
/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.