Skip to contentSkip to conversation

dvb_net_ule(): fix check-after-use

PATCH In review Adrian Bunk 2 participants 2 messages Aug 14, 2007 – Aug 16, 2007 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dvb_net_ule(): fix check-after-use

The Coverity checker spotted that we'd have already oops'ed if "dev" was NULL.

---

drivers/media/dvb/dvb-core/dvb_net.c renamed from drivers/media/dvb/dvb-core/dvb_net.c.old +0 -5
@@ -346,33 +346,28 @@
 static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
 {
 	struct dvb_net_priv *priv = dev->priv;
 	unsigned long skipped = 0L;
 	const u8 *ts, *ts_end, *from_where = NULL;
 	u8 ts_remain = 0, how_much = 0, new_ts = 1;
 	struct ethhdr *ethh = NULL;
 
 #ifdef ULE_DEBUG
 	/* The code inside ULE_DEBUG keeps a history of the last 100 TS cells processed. */
 	static unsigned char ule_hist[100*TS_SZ];
 	static unsigned char *ule_where = ule_hist, ule_dump = 0;
 #endif
 
-	if (dev == NULL) {
-		printk( KERN_ERR "NO netdev struct!\n" );
-		return;
-	}
-
 	/* For all TS cells in current buffer.
 	 * Appearently, we are called for every single TS cell.
 	 */
 	for (ts = buf, ts_end = buf + buf_len; ts < ts_end; /* no default incr. */ ) {
 
 		if (new_ts) {
 			/* We are about to process a new TS cell. */
 
 #ifdef ULE_DEBUG
 			if (ule_where >= &ule_hist[100*TS_SZ]) ule_where = ule_hist;
 			memcpy( ule_where, ts, TS_SZ );
 			if (ule_dump) {
 				hexdump( ule_where, TS_SZ );
 				ule_dump = 0;
#1 lore raw
Quoted 34 lines · Adrian Bunk

The Coverity checker spotted that we'd have already oops'ed if "dev" was NULL.

---

drivers/media/dvb/dvb-core/dvb_net.c renamed from drivers/media/dvb/dvb-core/dvb_net.c.old +0 -5
@@ -346,33 +346,28 @@
 static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
 {
 	struct dvb_net_priv *priv = dev->priv;
 	unsigned long skipped = 0L;
 	const u8 *ts, *ts_end, *from_where = NULL;
 	u8 ts_remain = 0, how_much = 0, new_ts = 1;
 	struct ethhdr *ethh = NULL;
 
 #ifdef ULE_DEBUG
 	/* The code inside ULE_DEBUG keeps a history of the last 100 TS cells processed. */
 	static unsigned char ule_hist[100*TS_SZ];
 	static unsigned char *ule_where = ule_hist, ule_dump = 0;
 #endif
 
-	if (dev == NULL) {
-		printk( KERN_ERR "NO netdev struct!\n" );
-		return;
-	}
-
 	/* For all TS cells in current buffer.
 	 * Appearently, we are called for every single TS cell.
 	 */
 	for (ts = buf, ts_end = buf + buf_len; ts < ts_end; /* no default incr. */ ) {

drivers/media/dvb/dvb-core/dvb_net.c line 373

Quoted 10 lines
drivers/media/dvb/dvb-core/dvb_net.c renamed from drivers/media/dvb/dvb-core/dvb_net.c.old +0 -0
 
 		if (new_ts) {
 			/* We are about to process a new TS cell. */
 
 #ifdef ULE_DEBUG
 			if (ule_where >= &ule_hist[100*TS_SZ]) ule_where = ule_hist;
 			memcpy( ule_where, ts, TS_SZ );
 			if (ule_dump) {
 				hexdump( ule_where, TS_SZ );
 				ule_dump = 0;