From: Takashi Iwai <tiwai@suse.de>
To: "Geyslan G. Bem" <geyslan@gmail.com>
Cc: kernel-br@googlegroups.com, Jaroslav Kysela <perex@perex.cz>,
Bill Pemberton <wfp5p@virginia.edu>,
alsa-devel@alsa-project.org (moderated list:SOUND),
linux-kernel@vger.kernel.org (open list)
Subject: Re: [PATCH v3] sound: pci: emu10k1: code refactoring
Date: Fri, 18 Oct 2013 08:59:35 +0200 [thread overview]
Message-ID: <s5hr4bjoyi0.wl%tiwai@suse.de> (raw)
In-Reply-To: <1382050633-21120-1-git-send-email-geyslan@gmail.com>
At Thu, 17 Oct 2013 19:57:12 -0300,
Geyslan G. Bem wrote:
>
> Partially restructures _snd_emu10k1_audigy_init_efx() and
> _snd_emu10k1_init_efx() functions.
>
> Be noted that the cast is demanded to use '__user'. So, in these cases,
> avoid patches based on the coccinelle 'drop_kmalloc_cast' semantic patch.
>
> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
Thanks, applied.
Takashi
> ---
> sound/pci/emu10k1/emufx.c | 76 ++++++++++++++++++++++++++++-------------------
> 1 file changed, 45 insertions(+), 31 deletions(-)
>
> diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
> index 0275209..1f9c7c4 100644
> --- a/sound/pci/emu10k1/emufx.c
> +++ b/sound/pci/emu10k1/emufx.c
> @@ -1182,15 +1182,20 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
> u32 *gpr_map;
> mm_segment_t seg;
>
> - if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL ||
> - (icode->gpr_map = (u_int32_t __user *)
> - kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t),
> - GFP_KERNEL)) == NULL ||
> - (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
> - sizeof(*controls), GFP_KERNEL)) == NULL) {
> - err = -ENOMEM;
> - goto __err;
> - }
> + err = -ENOMEM;
> + icode = kzalloc(sizeof(*icode), GFP_KERNEL);
> + if (!icode)
> + return err;
> +
> + icode->gpr_map = (u_int32_t __user *) kcalloc(512 + 256 + 256 + 2 * 1024,
> + sizeof(u_int32_t), GFP_KERNEL);
> + if (!icode->gpr_map)
> + goto __err_gpr;
> + controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
> + sizeof(*controls), GFP_KERNEL);
> + if (!controls)
> + goto __err_ctrls;
> +
> gpr_map = (u32 __force *)icode->gpr_map;
>
> icode->tram_data_map = icode->gpr_map + 512;
> @@ -1741,12 +1746,12 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
> emu->support_tlv = 0; /* clear again */
> snd_leave_user(seg);
>
> - __err:
> +__err:
> kfree(controls);
> - if (icode != NULL) {
> - kfree((void __force *)icode->gpr_map);
> - kfree(icode);
> - }
> +__err_ctrls:
> + kfree((void __force *)icode->gpr_map);
> +__err_gpr:
> + kfree(icode);
> return err;
> }
>
> @@ -1813,18 +1818,26 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
> u32 *gpr_map;
> mm_segment_t seg;
>
> - if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL)
> - return -ENOMEM;
> - if ((icode->gpr_map = (u_int32_t __user *)
> - kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t),
> - GFP_KERNEL)) == NULL ||
> - (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
> - sizeof(struct snd_emu10k1_fx8010_control_gpr),
> - GFP_KERNEL)) == NULL ||
> - (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) {
> - err = -ENOMEM;
> - goto __err;
> - }
> + err = -ENOMEM;
> + icode = kzalloc(sizeof(*icode), GFP_KERNEL);
> + if (!icode)
> + return err;
> +
> + icode->gpr_map = (u_int32_t __user *) kcalloc(256 + 160 + 160 + 2 * 512,
> + sizeof(u_int32_t), GFP_KERNEL);
> + if (!icode->gpr_map)
> + goto __err_gpr;
> +
> + controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
> + sizeof(struct snd_emu10k1_fx8010_control_gpr),
> + GFP_KERNEL);
> + if (!controls)
> + goto __err_ctrls;
> +
> + ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL);
> + if (!ipcm)
> + goto __err_ipcm;
> +
> gpr_map = (u32 __force *)icode->gpr_map;
>
> icode->tram_data_map = icode->gpr_map + 256;
> @@ -2363,13 +2376,14 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
> snd_leave_user(seg);
> if (err >= 0)
> err = snd_emu10k1_ipcm_poke(emu, ipcm);
> - __err:
> +__err:
> kfree(ipcm);
> +__err_ipcm:
> kfree(controls);
> - if (icode != NULL) {
> - kfree((void __force *)icode->gpr_map);
> - kfree(icode);
> - }
> +__err_ctrls:
> + kfree((void __force *)icode->gpr_map);
> +__err_gpr:
> + kfree(icode);
> return err;
> }
>
> --
> 1.8.4
>
prev parent reply other threads:[~2013-10-18 6:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-17 22:57 Geyslan G. Bem
2013-10-18 6:59 ` Takashi Iwai [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=s5hr4bjoyi0.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=geyslan@gmail.com \
--cc=kernel-br@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=wfp5p@virginia.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®