On Mon, Sep 28, 2009 at 00:08, <[email protected]> wrote:
> Check 'chip' in error handling code to prevent NULL pointer access.
>
> --- trunk/drivers/spi/spi_bfin5xx.c 2009-09-28 04:03:38 UTC (rev 7479)
> +++ trunk/drivers/spi/spi_bfin5xx.c 2009-09-28 04:08:13 UTC (rev 7480)
> @@ -1062,7 +1062,7 @@
> int ret = -EINVAL;
>
> if (spi->bits_per_word != 8 && spi->bits_per_word != 16)
> - goto error;
> + return -EINVAL;
>
> /* Only alloc (or use chip_info) on first setup */
> chip_info = NULL;
> @@ -1212,6 +1212,9 @@
>
> error:
> if (ret) {
> + if (!chip)
> + return ret;
> +
> if (drv_data->dma_requested)
> free_dma(drv_data->dma_channel);
> drv_data->dma_requested = 0;
i dont think both of these changes are needed. if you check the chip
pointer, then the first error check can safely jump to the error
label.
i think it'd be better if the code were:
if (ret && chip) {
....
then we can have all error paths jump to error instead of having a mix
of some returns and some goto's.
-mike
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits