gspca: add sanity check for mandatory operations

Message ID 4B02470C.7000205@freemail.hu (mailing list archive)
State Superseded, archived
Headers

Commit Message

Németh Márton Nov. 17, 2009, 6:47 a.m. UTC
  From: Márton Németh <nm127@fremail.hu>

Add check for the mandatory config, init, start and pkt_scan
gspca subdriver operations.

Signed-off-by: Márton Németh <nm127@fremail.hu>
---
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Comments

Jean-Francois Moine Nov. 17, 2009, 9:51 a.m. UTC | #1
On Tue, 17 Nov 2009 07:47:40 +0100
Németh Márton <nm127@freemail.hu> wrote:

> From: Márton Németh <nm127@fremail.hu>
> 
> Add check for the mandatory config, init, start and pkt_scan
> gspca subdriver operations.
> 
> Signed-off-by: Márton Németh <nm127@fremail.hu>
> ---
> diff -r 182b5f8fa160 linux/drivers/media/video/gspca/gspca.c
> --- a/linux/drivers/media/video/gspca/gspca.c	Sun Nov 15
> 10:05:30 2009 +0100 +++
> b/linux/drivers/media/video/gspca/gspca.c	Tue Nov 17 07:42:34
> 2009 +0100 @@ -2035,6 +2035,12 @@ return -ENODEV;
>  	}
> 
> +	/* check for mandatory operations */
> +	BUG_ON(!sd_desc->config);
> +	BUG_ON(!sd_desc->init);
> +	BUG_ON(!sd_desc->start);
> +	BUG_ON(!sd_desc->pkt_scan);
> +
>  	/* create the device */
>  	if (dev_size < sizeof *gspca_dev)
>  		dev_size = sizeof *gspca_dev;

Hi Németh,

I don't think this is useful: the people who write the subdrivers know
the mandatory parameters. If not, the system will simply oops at the
first test...
  

Patch

diff -r 182b5f8fa160 linux/drivers/media/video/gspca/gspca.c
--- a/linux/drivers/media/video/gspca/gspca.c	Sun Nov 15 10:05:30 2009 +0100
+++ b/linux/drivers/media/video/gspca/gspca.c	Tue Nov 17 07:42:34 2009 +0100
@@ -2035,6 +2035,12 @@ 
 		return -ENODEV;
 	}

+	/* check for mandatory operations */
+	BUG_ON(!sd_desc->config);
+	BUG_ON(!sd_desc->init);
+	BUG_ON(!sd_desc->start);
+	BUG_ON(!sd_desc->pkt_scan);
+
 	/* create the device */
 	if (dev_size < sizeof *gspca_dev)
 		dev_size = sizeof *gspca_dev;