[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201204222234.59624.marex@denx.de>
Date: Sun, 22 Apr 2012 22:34:59 +0200
From: Marek Vasut <marex@...x.de>
To: Jesper Juhl <jj@...osbits.net>
Cc: linux-kernel@...r.kernel.org,
Felipe Contreras <felipe.contreras@...il.com>,
Felipe Balbi <balbi@...com>,
Anton Vorontsov <anton.vorontsov@...aro.org>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Kalle Jokiniemi <kalle.jokiniemi@...ia.com>
Subject: Re: [PATCH] ISP1704 USB Charger: Fix use-after-free error in isp1704_charger_probe()
Dear Jesper Juhl,
> In isp1704_charger_probe() at the 'fail0:' label we kfree(isp) and
> then subsequently call isp1704_charger_set_power(isp, 0). That's a
> problem since isp1704_charger_set_power() dereferences the pointer it
> is passed as its first argument, which is 'isp', which we already
> freed.
>
> Fixed by simply swapping the order of the two calls so that we only
> kfree() *after* the call to isp1704_charger_set_power().
>
> Signed-off-by: Jesper Juhl <jj@...osbits.net>
> ---
> drivers/power/isp1704_charger.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/power/isp1704_charger.c
> b/drivers/power/isp1704_charger.c index 39eb50f..8a610da 100644
> --- a/drivers/power/isp1704_charger.c
> +++ b/drivers/power/isp1704_charger.c
> @@ -476,11 +476,9 @@ fail2:
> fail1:
> usb_put_transceiver(isp->phy);
> fail0:
> - kfree(isp);
> -
> dev_err(&pdev->dev, "failed to register isp1704 with error %d\n", ret);
> -
> isp1704_charger_set_power(isp, 0);
> + kfree(isp);
Use devm_kzalloc() and be done with all this goo?
> return ret;
> }
Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists