Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (12440): Use kzalloc for frontend states to have struct dvb_frontend properly

This patch changes most frontend drivers to allocate their state structure via
kzalloc and not kmalloc. This is done to properly initialize the
embedded "struct dvb_frontend frontend" field, that they all have.

The visible effect of this struct being uninitalized is, that the member "id"
that is used to set the name of kernel thread is totally random.

Some board drivers (for example cx88-dvb) set this "id" via
videobuf_dvb_alloc_frontend but most do not.

So I at least get random id values for saa7134, flexcop and ttpci based cards.
It looks like this in dmesg:
DVB: registering adapter 1 frontend -10551321 (ST STV0299 DVB-S)

The related kernel thread then also gets a strange name
like "kdvb-ad-1-fe--1".

Cc: Michael Krufky <mkrufky@linuxtv.org>
Cc: Steven Toth <stoth@linuxtv.org>
Cc: Timothy Lee <timothy.lee@siriushk.com>
Cc: Igor M. Liplianin <liplianin@me.by>
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Acked-by: Andreas Oberritter <obi@linuxtv.org>
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Matthias Schwarzott and committed by
Mauro Carvalho Chehab
084e24ac bb2b4542

+28 -28
+1 -1
drivers/media/dvb/frontends/cx22700.c
··· 380 380 struct cx22700_state* state = NULL; 381 381 382 382 /* allocate memory for the internal state */ 383 - state = kmalloc(sizeof(struct cx22700_state), GFP_KERNEL); 383 + state = kzalloc(sizeof(struct cx22700_state), GFP_KERNEL); 384 384 if (state == NULL) goto error; 385 385 386 386 /* setup the state */
+1 -1
drivers/media/dvb/frontends/cx22702.c
··· 580 580 struct cx22702_state *state = NULL; 581 581 582 582 /* allocate memory for the internal state */ 583 - state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL); 583 + state = kzalloc(sizeof(struct cx22702_state), GFP_KERNEL); 584 584 if (state == NULL) 585 585 goto error; 586 586
+1 -1
drivers/media/dvb/frontends/cx24110.c
··· 598 598 int ret; 599 599 600 600 /* allocate memory for the internal state */ 601 - state = kmalloc(sizeof(struct cx24110_state), GFP_KERNEL); 601 + state = kzalloc(sizeof(struct cx24110_state), GFP_KERNEL); 602 602 if (state == NULL) goto error; 603 603 604 604 /* setup the state */
+3 -3
drivers/media/dvb/frontends/dvb_dummy_fe.c
··· 117 117 struct dvb_dummy_fe_state* state = NULL; 118 118 119 119 /* allocate memory for the internal state */ 120 - state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 120 + state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 121 121 if (state == NULL) goto error; 122 122 123 123 /* create dvb_frontend */ ··· 137 137 struct dvb_dummy_fe_state* state = NULL; 138 138 139 139 /* allocate memory for the internal state */ 140 - state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 140 + state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 141 141 if (state == NULL) goto error; 142 142 143 143 /* create dvb_frontend */ ··· 157 157 struct dvb_dummy_fe_state* state = NULL; 158 158 159 159 /* allocate memory for the internal state */ 160 - state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 160 + state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 161 161 if (state == NULL) goto error; 162 162 163 163 /* create dvb_frontend */
+1 -1
drivers/media/dvb/frontends/l64781.c
··· 501 501 { .addr = config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; 502 502 503 503 /* allocate memory for the internal state */ 504 - state = kmalloc(sizeof(struct l64781_state), GFP_KERNEL); 504 + state = kzalloc(sizeof(struct l64781_state), GFP_KERNEL); 505 505 if (state == NULL) goto error; 506 506 507 507 /* setup the state */
+1 -1
drivers/media/dvb/frontends/lgs8gl5.c
··· 387 387 dprintk("%s\n", __func__); 388 388 389 389 /* Allocate memory for the internal state */ 390 - state = kmalloc(sizeof(struct lgs8gl5_state), GFP_KERNEL); 390 + state = kzalloc(sizeof(struct lgs8gl5_state), GFP_KERNEL); 391 391 if (state == NULL) 392 392 goto error; 393 393
+1 -1
drivers/media/dvb/frontends/mt312.c
··· 782 782 struct mt312_state *state = NULL; 783 783 784 784 /* allocate memory for the internal state */ 785 - state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL); 785 + state = kzalloc(sizeof(struct mt312_state), GFP_KERNEL); 786 786 if (state == NULL) 787 787 goto error; 788 788
+1 -1
drivers/media/dvb/frontends/nxt6000.c
··· 545 545 struct nxt6000_state* state = NULL; 546 546 547 547 /* allocate memory for the internal state */ 548 - state = kmalloc(sizeof(struct nxt6000_state), GFP_KERNEL); 548 + state = kzalloc(sizeof(struct nxt6000_state), GFP_KERNEL); 549 549 if (state == NULL) goto error; 550 550 551 551 /* setup the state */
+1 -1
drivers/media/dvb/frontends/or51132.c
··· 562 562 struct or51132_state* state = NULL; 563 563 564 564 /* Allocate memory for the internal state */ 565 - state = kmalloc(sizeof(struct or51132_state), GFP_KERNEL); 565 + state = kzalloc(sizeof(struct or51132_state), GFP_KERNEL); 566 566 if (state == NULL) 567 567 return NULL; 568 568
+1 -1
drivers/media/dvb/frontends/or51211.c
··· 527 527 struct or51211_state* state = NULL; 528 528 529 529 /* Allocate memory for the internal state */ 530 - state = kmalloc(sizeof(struct or51211_state), GFP_KERNEL); 530 + state = kzalloc(sizeof(struct or51211_state), GFP_KERNEL); 531 531 if (state == NULL) 532 532 return NULL; 533 533
+1 -1
drivers/media/dvb/frontends/s5h1409.c
··· 796 796 u16 reg; 797 797 798 798 /* allocate memory for the internal state */ 799 - state = kmalloc(sizeof(struct s5h1409_state), GFP_KERNEL); 799 + state = kzalloc(sizeof(struct s5h1409_state), GFP_KERNEL); 800 800 if (state == NULL) 801 801 goto error; 802 802
+1 -1
drivers/media/dvb/frontends/s5h1411.c
··· 844 844 u16 reg; 845 845 846 846 /* allocate memory for the internal state */ 847 - state = kmalloc(sizeof(struct s5h1411_state), GFP_KERNEL); 847 + state = kzalloc(sizeof(struct s5h1411_state), GFP_KERNEL); 848 848 if (state == NULL) 849 849 goto error; 850 850
+1 -1
drivers/media/dvb/frontends/si21xx.c
··· 928 928 dprintk("%s\n", __func__); 929 929 930 930 /* allocate memory for the internal state */ 931 - state = kmalloc(sizeof(struct si21xx_state), GFP_KERNEL); 931 + state = kzalloc(sizeof(struct si21xx_state), GFP_KERNEL); 932 932 if (state == NULL) 933 933 goto error; 934 934
+1 -1
drivers/media/dvb/frontends/sp8870.c
··· 557 557 struct sp8870_state* state = NULL; 558 558 559 559 /* allocate memory for the internal state */ 560 - state = kmalloc(sizeof(struct sp8870_state), GFP_KERNEL); 560 + state = kzalloc(sizeof(struct sp8870_state), GFP_KERNEL); 561 561 if (state == NULL) goto error; 562 562 563 563 /* setup the state */
+1 -1
drivers/media/dvb/frontends/sp887x.c
··· 557 557 struct sp887x_state* state = NULL; 558 558 559 559 /* allocate memory for the internal state */ 560 - state = kmalloc(sizeof(struct sp887x_state), GFP_KERNEL); 560 + state = kzalloc(sizeof(struct sp887x_state), GFP_KERNEL); 561 561 if (state == NULL) goto error; 562 562 563 563 /* setup the state */
+1 -1
drivers/media/dvb/frontends/stv0288.c
··· 570 570 int id; 571 571 572 572 /* allocate memory for the internal state */ 573 - state = kmalloc(sizeof(struct stv0288_state), GFP_KERNEL); 573 + state = kzalloc(sizeof(struct stv0288_state), GFP_KERNEL); 574 574 if (state == NULL) 575 575 goto error; 576 576
+1 -1
drivers/media/dvb/frontends/stv0297.c
··· 663 663 struct stv0297_state *state = NULL; 664 664 665 665 /* allocate memory for the internal state */ 666 - state = kmalloc(sizeof(struct stv0297_state), GFP_KERNEL); 666 + state = kzalloc(sizeof(struct stv0297_state), GFP_KERNEL); 667 667 if (state == NULL) 668 668 goto error; 669 669
+1 -1
drivers/media/dvb/frontends/stv0299.c
··· 667 667 int id; 668 668 669 669 /* allocate memory for the internal state */ 670 - state = kmalloc(sizeof(struct stv0299_state), GFP_KERNEL); 670 + state = kzalloc(sizeof(struct stv0299_state), GFP_KERNEL); 671 671 if (state == NULL) goto error; 672 672 673 673 /* setup the state */
+1 -1
drivers/media/dvb/frontends/tda10021.c
··· 413 413 u8 id; 414 414 415 415 /* allocate memory for the internal state */ 416 - state = kmalloc(sizeof(struct tda10021_state), GFP_KERNEL); 416 + state = kzalloc(sizeof(struct tda10021_state), GFP_KERNEL); 417 417 if (state == NULL) goto error; 418 418 419 419 /* setup the state */
+1 -1
drivers/media/dvb/frontends/tda10048.c
··· 1095 1095 dprintk(1, "%s()\n", __func__); 1096 1096 1097 1097 /* allocate memory for the internal state */ 1098 - state = kmalloc(sizeof(struct tda10048_state), GFP_KERNEL); 1098 + state = kzalloc(sizeof(struct tda10048_state), GFP_KERNEL); 1099 1099 if (state == NULL) 1100 1100 goto error; 1101 1101
+2 -2
drivers/media/dvb/frontends/tda1004x.c
··· 1269 1269 int id; 1270 1270 1271 1271 /* allocate memory for the internal state */ 1272 - state = kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL); 1272 + state = kzalloc(sizeof(struct tda1004x_state), GFP_KERNEL); 1273 1273 if (!state) { 1274 1274 printk(KERN_ERR "Can't alocate memory for tda10045 state\n"); 1275 1275 return NULL; ··· 1339 1339 int id; 1340 1340 1341 1341 /* allocate memory for the internal state */ 1342 - state = kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL); 1342 + state = kzalloc(sizeof(struct tda1004x_state), GFP_KERNEL); 1343 1343 if (!state) { 1344 1344 printk(KERN_ERR "Can't alocate memory for tda10046 state\n"); 1345 1345 return NULL;
+1 -1
drivers/media/dvb/frontends/tda10086.c
··· 745 745 dprintk ("%s\n", __func__); 746 746 747 747 /* allocate memory for the internal state */ 748 - state = kmalloc(sizeof(struct tda10086_state), GFP_KERNEL); 748 + state = kzalloc(sizeof(struct tda10086_state), GFP_KERNEL); 749 749 if (!state) 750 750 return NULL; 751 751
+1 -1
drivers/media/dvb/frontends/tda8083.c
··· 417 417 struct tda8083_state* state = NULL; 418 418 419 419 /* allocate memory for the internal state */ 420 - state = kmalloc(sizeof(struct tda8083_state), GFP_KERNEL); 420 + state = kzalloc(sizeof(struct tda8083_state), GFP_KERNEL); 421 421 if (state == NULL) goto error; 422 422 423 423 /* setup the state */
+1 -1
drivers/media/dvb/frontends/ves1820.c
··· 374 374 struct ves1820_state* state = NULL; 375 375 376 376 /* allocate memory for the internal state */ 377 - state = kmalloc(sizeof(struct ves1820_state), GFP_KERNEL); 377 + state = kzalloc(sizeof(struct ves1820_state), GFP_KERNEL); 378 378 if (state == NULL) 379 379 goto error; 380 380
+1 -1
drivers/media/dvb/frontends/ves1x93.c
··· 456 456 u8 identity; 457 457 458 458 /* allocate memory for the internal state */ 459 - state = kmalloc(sizeof(struct ves1x93_state), GFP_KERNEL); 459 + state = kzalloc(sizeof(struct ves1x93_state), GFP_KERNEL); 460 460 if (state == NULL) goto error; 461 461 462 462 /* setup the state */