All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Hui Wang <hui.wang@canonical.com>
Cc: alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com
Subject: Re: [RFC][PATCH v4 1/4] alsa: jack: implement software jack injection via debugfs
Date: Wed, 20 Jan 2021 15:51:36 +0100	[thread overview]
Message-ID: <s5h5z3rek5j.wl-tiwai@suse.de> (raw)
In-Reply-To: <20210111130557.90208-2-hui.wang@canonical.com>

On Mon, 11 Jan 2021 14:05:54 +0100,
Hui Wang wrote:
> +static ssize_t sw_inject_enable_read(struct file *file,
> +				     char __user *to, size_t count, loff_t *ppos)
> +{
> +	struct snd_jack_kctl *jack_kctl = file->private_data;
> +	char *buf;
> +	int len, ret;
> +
> +	buf = kvzalloc(PAGE_SIZE, GFP_KERNEL);
> +	if (!buf)
> +		return -ENOMEM;
> +
> +	len = scnprintf(buf, PAGE_SIZE, "%s: %s\t\t%s: %i\n", "Jack", jack_kctl->kctl->id.name,
> +			"Inject Enabled", jack_kctl->sw_inject_enable);
> +	ret = simple_read_from_buffer(to, count, ppos, buf, len);

For this size of a string buffer, you don't need to allocate via
kvmalloc().  It can be on stack.


> +static ssize_t sw_inject_enable_write(struct file *file,
> +				      const char __user *from, size_t count, loff_t *ppos)
> +{
> +	struct snd_jack_kctl *jack_kctl = file->private_data;
> +	char *buf;
> +	int ret, err;
> +	unsigned long enable;
> +
> +	buf = kvzalloc(count, GFP_KERNEL);
> +	if (!buf)
> +		return -ENOMEM;
> +
> +	ret = simple_write_to_buffer(buf, count, ppos, from, count);
> +	err = kstrtoul(buf, 0, &enable);

Ditto, it's just a single number and cannot be that big.
(Also jackin_inject_write(), too.)


thanks,

Takashi

  reply	other threads:[~2021-01-20 14:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 13:05 [RFC][PATCH v4 0/4] design a way to change audio Jack state by software Hui Wang
2021-01-11 13:05 ` [RFC][PATCH v4 1/4] alsa: jack: implement software jack injection via debugfs Hui Wang
2021-01-20 14:51   ` Takashi Iwai [this message]
2021-01-11 13:05 ` [RFC][PATCH v4 2/4] alsa: jack: adjust jack_kctl debugfs folder's name Hui Wang
2021-01-20 14:55   ` Takashi Iwai
2021-01-11 13:05 ` [RFC][PATCH v4 3/4] alsa: jack: add more jack_kctl debugfs nodes Hui Wang
2021-01-20 14:58   ` Takashi Iwai
2021-01-11 13:05 ` [RFC][PATCH v4 4/4] alsa: jack: implement save-and-restore for jack's hw status Hui Wang
2021-01-20  8:58 ` [RFC][PATCH v4 0/4] design a way to change audio Jack state by software Hui Wang
2021-01-20 14:47   ` Takashi Iwai
2021-01-21 12:48     ` Hui Wang

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=s5h5z3rek5j.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=hui.wang@canonical.com \
    --cc=kai.vehmanen@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.