[v4,34/37] mc: fix NULL pointer access in libnouveau

Submitted by Karol Herbst on April 18, 2016, 7:14 p.m.

Details

Message ID 1461006851-5007-35-git-send-email-nouveau@karolherbst.de
State New
Headers show
Series "Volting/Clocking improvements for Fermi and newer" ( rev: 4 ) in Nouveau

Not browsing as part of any series.

Commit Message

Karol Herbst April 18, 2016, 7:14 p.m.
Signed-off-by: Karol Herbst <nouveau@karolherbst.de>
---
 drm/nouveau/nvkm/subdev/mc/base.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drm/nouveau/nvkm/subdev/mc/base.c b/drm/nouveau/nvkm/subdev/mc/base.c
index aa394af..88bc1cc 100644
--- a/drm/nouveau/nvkm/subdev/mc/base.c
+++ b/drm/nouveau/nvkm/subdev/mc/base.c
@@ -90,10 +90,15 @@  nvkm_mc_intr(struct nvkm_mc *mc, bool *handled)
 void
 nvkm_mc_reset(struct nvkm_mc *mc, enum nvkm_devidx devidx)
 {
-	struct nvkm_device *device = mc->subdev.device;
+	struct nvkm_device *device;
 	const struct nvkm_mc_map *map;
 	u64 pmc_enable;
 
+	if (!mc)
+		return;
+
+	device = mc->subdev.device;
+
 	if (!(pmc_enable = nvkm_top_reset(device->top, devidx))) {
 		for (map = mc->func->reset; map && map->stat; map++) {
 			if (map->unit == devidx) {

Comments

On 18/04/16 22:14, Karol Herbst wrote:
> Signed-off-by: Karol Herbst <nouveau@karolherbst.de>
> ---
>   drm/nouveau/nvkm/subdev/mc/base.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drm/nouveau/nvkm/subdev/mc/base.c b/drm/nouveau/nvkm/subdev/mc/base.c
> index aa394af..88bc1cc 100644
> --- a/drm/nouveau/nvkm/subdev/mc/base.c
> +++ b/drm/nouveau/nvkm/subdev/mc/base.c
> @@ -90,10 +90,15 @@ nvkm_mc_intr(struct nvkm_mc *mc, bool *handled)
>   void
>   nvkm_mc_reset(struct nvkm_mc *mc, enum nvkm_devidx devidx)
>   {
> -	struct nvkm_device *device = mc->subdev.device;
> +	struct nvkm_device *device;
>   	const struct nvkm_mc_map *map;
>   	u64 pmc_enable;
>   
> +	if (!mc)
> +		return;
Not sure what is the policy of Ben on this, fixing the caller or the 
callee. His call!
> +
> +	device = mc->subdev.device;
> +
>   	if (!(pmc_enable = nvkm_top_reset(device->top, devidx))) {
>   		for (map = mc->func->reset; map && map->stat; map++) {
>   			if (map->unit == devidx) {