public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Johannes Stezenbach <js@linuxtv.org>
To: emagick@magic.ms
Cc: linux-media@vger.kernel.org
Subject: Re: Patch for  stack/DMA problems in Cinergy T2 drivers (2)
Date: Fri, 31 Jul 2009 23:40:46 +0200	[thread overview]
Message-ID: <20090731214046.GA28139@linuxtv.org> (raw)
In-Reply-To: <4A735330.1000406@magic.ms>

On Fri, Jul 31, 2009 at 10:25:20PM +0200, emagick@magic.ms wrote:
> Here's a patch for cinergyT2-core.c:
> 
> --- a/drivers/media/dvb/dvb-usb/cinergyT2-fe.c	2009-06-10 05:05:27.000000000 +0200
> +++ b/drivers/media/dvb/dvb-usb/cinergyT2-fe.c	2009-07-31 22:02:48.000000000 +0200
> @@ -146,66 +146,103 @@
>  					fe_status_t *status)
>  {
>  	struct cinergyt2_fe_state *state = fe->demodulator_priv;
> -	struct dvbt_get_status_msg result;
> -	u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
> +	struct dvbt_get_status_msg *result;
> +	static const u8 cmd0[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
> +        u8 *cmd;
>  	int ret;
> 
> -	ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&result,
> -			sizeof(result), 0);
> -	if (ret < 0)
> +        cmd = kmalloc(sizeof(cmd0), GFP_KERNEL);
> +        if (!cmd) return -ENOMEM;
> +        memcpy(cmd, cmd0, sizeof(cmd0));
> +        result = kmalloc(sizeof(*result), GFP_KERNEL);
> +        if (!result) {
> +                kfree(cmd);
> +                return -ENOMEM;
> +        }
> +	ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd0), (u8 *)result,
> +			sizeof(*result), 0);
> +        kfree(cmd);
> +	if (ret < 0) {
> +                kfree(result);
>  		return ret;
> +        }

There is a fair amount of code duplication.  A better aproach would
be to allocate buffers once in cinergyt2_fe_attach()
(add them to struct cinergyt2_fe_state).

And please observe http://linuxtv.org/hg/v4l-dvb/raw-file/tip/README.patches

  reply	other threads:[~2009-07-31 21:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-31 20:25 Patch for stack/DMA problems in Cinergy T2 drivers (2) emagick
2009-07-31 21:40 ` Johannes Stezenbach [this message]
2009-08-01  8:27   ` emagick
2009-08-01 13:23     ` emagick
2009-08-01 13:34   ` emagick
2009-08-01 16:00 ` Nils Kassube

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=20090731214046.GA28139@linuxtv.org \
    --to=js@linuxtv.org \
    --cc=emagick@magic.ms \
    --cc=linux-media@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox