public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dvb_demux: Don't use vmalloc at dvb_dmx_swfilter_packet
@ 2010-02-01 14:50 Mauro Carvalho Chehab
  2010-02-05  2:54 ` Andy Walls
  0 siblings, 1 reply; 2+ messages in thread
From: Mauro Carvalho Chehab @ 2010-02-01 14:50 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Abylay Ospan

As dvb_dmx_swfilter_packet() is protected by a spinlock, it shouldn't sleep.
However, vmalloc() may call sleep. So, move the initialization of
dvb_demux::cnt_storage field to a better place.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb/dvb-core/dvb_demux.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
index a78408e..67f189b 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb/dvb-core/dvb_demux.c
@@ -426,16 +426,7 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
 		};
 	};
 
-	if (dvb_demux_tscheck) {
-		if (!demux->cnt_storage)
-			demux->cnt_storage = vmalloc(MAX_PID + 1);
-
-		if (!demux->cnt_storage) {
-			printk(KERN_WARNING "Couldn't allocate memory for TS/TEI check. Disabling it\n");
-			dvb_demux_tscheck = 0;
-			goto no_dvb_demux_tscheck;
-		}
-
+	if (demux->cnt_storage) {
 		/* check pkt counter */
 		if (pid < MAX_PID) {
 			if (buf[1] & 0x80)
@@ -454,7 +445,6 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
 		};
 		/* end check */
 	};
-no_dvb_demux_tscheck:
 
 	list_for_each_entry(feed, &demux->feed_list, list_head) {
 		if ((feed->pid != pid) && (feed->pid != 0x2000))
@@ -1258,6 +1248,13 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
 		dvbdemux->feed[i].index = i;
 	}
 
+	if (dvb_demux_tscheck) {
+		dvbdemux->cnt_storage = vmalloc(MAX_PID + 1);
+
+		if (!dvbdemux->cnt_storage)
+			printk(KERN_WARNING "Couldn't allocate memory for TS/TEI check. Disabling it\n");
+	}
+
 	INIT_LIST_HEAD(&dvbdemux->frontend_list);
 
 	for (i = 0; i < DMX_TS_PES_OTHER; i++) {
-- 
1.6.6.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dvb_demux: Don't use vmalloc at dvb_dmx_swfilter_packet
  2010-02-01 14:50 [PATCH] dvb_demux: Don't use vmalloc at dvb_dmx_swfilter_packet Mauro Carvalho Chehab
@ 2010-02-05  2:54 ` Andy Walls
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Walls @ 2010-02-05  2:54 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, Abylay Ospan

On Mon, 2010-02-01 at 12:50 -0200, Mauro Carvalho Chehab wrote:
> As dvb_dmx_swfilter_packet() is protected by a spinlock, it shouldn't sleep.
> However, vmalloc() may call sleep. So, move the initialization of
> dvb_demux::cnt_storage field to a better place.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

Looks good.  In fact it is slightly better in that it doesn't disable
the global module option for all following demuxes simply for one
vmalloc() failure.

Reviewed-by: Andy Walls <awalls@radix.net>

Regards,
Andy

> ---
>  drivers/media/dvb/dvb-core/dvb_demux.c |   19 ++++++++-----------
>  1 files changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
> index a78408e..67f189b 100644
> --- a/drivers/media/dvb/dvb-core/dvb_demux.c
> +++ b/drivers/media/dvb/dvb-core/dvb_demux.c
> @@ -426,16 +426,7 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
>  		};
>  	};
>  
> -	if (dvb_demux_tscheck) {
> -		if (!demux->cnt_storage)
> -			demux->cnt_storage = vmalloc(MAX_PID + 1);
> -
> -		if (!demux->cnt_storage) {
> -			printk(KERN_WARNING "Couldn't allocate memory for TS/TEI check. Disabling it\n");
> -			dvb_demux_tscheck = 0;
> -			goto no_dvb_demux_tscheck;
> -		}
> -
> +	if (demux->cnt_storage) {
>  		/* check pkt counter */
>  		if (pid < MAX_PID) {
>  			if (buf[1] & 0x80)
> @@ -454,7 +445,6 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
>  		};
>  		/* end check */
>  	};
> -no_dvb_demux_tscheck:
>  
>  	list_for_each_entry(feed, &demux->feed_list, list_head) {
>  		if ((feed->pid != pid) && (feed->pid != 0x2000))
> @@ -1258,6 +1248,13 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
>  		dvbdemux->feed[i].index = i;
>  	}
>  
> +	if (dvb_demux_tscheck) {
> +		dvbdemux->cnt_storage = vmalloc(MAX_PID + 1);
> +
> +		if (!dvbdemux->cnt_storage)
> +			printk(KERN_WARNING "Couldn't allocate memory for TS/TEI check. Disabling it\n");
> +	}
> +
>  	INIT_LIST_HEAD(&dvbdemux->frontend_list);
>  
>  	for (i = 0; i < DMX_TS_PES_OTHER; i++) {


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-05  2:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-01 14:50 [PATCH] dvb_demux: Don't use vmalloc at dvb_dmx_swfilter_packet Mauro Carvalho Chehab
2010-02-05  2:54 ` Andy Walls

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox