Re: [PATCH v2] x86: punit_atom: punit device state debug driver

From: Thomas Gleixner
Date: Mon May 04 2015 - 15:40:55 EST


On Mon, 4 May 2015, Srinivas Pandruvada wrote:
> +struct punit_device {
> + char *name;
> + int reg;
> + int sss_pos;
> +};
> +
> +static struct punit_device *punit_device;

So this pointer gets initialized in punit_atom_debug_init() and points
either to punit_device_byt or punit_device_cht.

> +static const struct punit_device punit_device_byt[] = {
> + { "GFX RENDER", PWRGT_STATUS, RENDER_POS },
...
> + { NULL }
> +};

> +static int punit_dev_state_show(struct seq_file *seq_file, void *unused)
> +{
> + u32 punit_pwr_status;
> + int index;
> + int status;
> +
> + seq_puts(seq_file, "\n\nPUNIT NORTH COMPLEX DEVICES :\n");
> + while (punit_device->name) {
> + status = iosf_mbi_read(PUNIT_PORT, BT_MBI_PMC_READ,
> + punit_device->reg,
> + &punit_pwr_status);
> + if (status)
> + seq_printf(seq_file, "%9s : Read Failed\n",
> + punit_device->name);
> + else {
> + index = (punit_pwr_status >> punit_device->sss_pos) & 3;
> + seq_printf(seq_file, "%9s : %s\n", punit_device->name,
> + dstates[index]);
> + }
> + punit_device++;

So you happily increment the above pointer. So after the first readout
of that debug file the pointer will point to the end of that
table. And any further readouts will simply fail.

Completely useless and untested crap.

Thanks,

tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/