Commit a5885855 authored by Marcin Slusarz's avatar Marcin Slusarz Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (7286): limit stack usage of ir-kbd-i2c.c



ir_probe allocated struct i2c_client on stack;
it's pretty big structure, so allocate it with kzalloc

make checkstack output without this patch:
x059d ir_probe [ir-kbd-i2c]:                           1000

Signed-off-by: default avatarMarcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 1c3bf598
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -509,7 +509,7 @@ static int ir_probe(struct i2c_adapter *adap)
	static const int probe_cx88[] = { 0x18, 0x6b, 0x71, -1 };
	static const int probe_cx23885[] = { 0x6b, -1 };
	const int *probe = NULL;
	struct i2c_client c;
	struct i2c_client *c;
	unsigned char buf;
	int i, rc;

@@ -536,11 +536,14 @@ static int ir_probe(struct i2c_adapter *adap)
	if (NULL == probe)
		return 0;

	memset(&c,0,sizeof(c));
	c.adapter = adap;
	c = kzalloc(sizeof(*c), GFP_KERNEL);
	if (!c)
		return -ENOMEM;

	c->adapter = adap;
	for (i = 0; -1 != probe[i]; i++) {
		c.addr = probe[i];
		rc = i2c_master_recv(&c,&buf,0);
		c->addr = probe[i];
		rc = i2c_master_recv(c, &buf, 0);
		dprintk(1,"probe 0x%02x @ %s: %s\n",
			probe[i], adap->name,
			(0 == rc) ? "yes" : "no");
@@ -549,6 +552,7 @@ static int ir_probe(struct i2c_adapter *adap)
			break;
		}
	}
	kfree(c);
	return 0;
}