From: Dan Carpenter <dan.carpenter@oracle.com> To: Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: David Airlie <airlied-cv59FeDIM0c@public.gmane.org>, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Subject: [PATCH] drm/nouveau/core: ERR_PTR vs NULL bug in nvkm_engine_info() Date: Wed, 30 May 2018 10:17:41 +0000 [thread overview] Message-ID: <20180530101741.yht7j7zupb6btdvn@kili.mountain> (raw) The nvkm_engine_ref() function returns error pointers, not NULL on error. I fixed that but I also had to reverse some of the checks so it didn't become too convoluted. Fixes: c5c9127b25b2 ("drm/nouveau/device: implement a generic method to query device-specific properties") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> diff --git a/drivers/gpu/drm/nouveau/nvkm/core/engine.c b/drivers/gpu/drm/nouveau/nvkm/core/engine.c index d0322ce85172..ee3fbee905e6 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/engine.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/engine.c @@ -86,14 +86,17 @@ static int nvkm_engine_info(struct nvkm_subdev *subdev, u64 mthd, u64 *data) { struct nvkm_engine *engine = nvkm_engine(subdev); - if (engine->func->info) { - if ((engine = nvkm_engine_ref(engine))) { - int ret = engine->func->info(engine, mthd, data); - nvkm_engine_unref(&engine); - return ret; - } - } - return -ENOSYS; + int ret; + + if (!engine->func->info) + return -ENOSYS; + + engine = nvkm_engine_ref(engine); + if (IS_ERR(engine)) + return PTR_ERR(engine); + ret = engine->func->info(engine, mthd, data); + nvkm_engine_unref(&engine); + return ret; } static int
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> To: Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: David Airlie <airlied-cv59FeDIM0c@public.gmane.org>, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Subject: [PATCH] drm/nouveau/core: ERR_PTR vs NULL bug in nvkm_engine_info() Date: Wed, 30 May 2018 13:17:41 +0300 [thread overview] Message-ID: <20180530101741.yht7j7zupb6btdvn@kili.mountain> (raw) The nvkm_engine_ref() function returns error pointers, not NULL on error. I fixed that but I also had to reverse some of the checks so it didn't become too convoluted. Fixes: c5c9127b25b2 ("drm/nouveau/device: implement a generic method to query device-specific properties") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> diff --git a/drivers/gpu/drm/nouveau/nvkm/core/engine.c b/drivers/gpu/drm/nouveau/nvkm/core/engine.c index d0322ce85172..ee3fbee905e6 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/engine.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/engine.c @@ -86,14 +86,17 @@ static int nvkm_engine_info(struct nvkm_subdev *subdev, u64 mthd, u64 *data) { struct nvkm_engine *engine = nvkm_engine(subdev); - if (engine->func->info) { - if ((engine = nvkm_engine_ref(engine))) { - int ret = engine->func->info(engine, mthd, data); - nvkm_engine_unref(&engine); - return ret; - } - } - return -ENOSYS; + int ret; + + if (!engine->func->info) + return -ENOSYS; + + engine = nvkm_engine_ref(engine); + if (IS_ERR(engine)) + return PTR_ERR(engine); + ret = engine->func->info(engine, mthd, data); + nvkm_engine_unref(&engine); + return ret; } static int _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau
next reply other threads:[~2018-05-30 10:17 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-05-30 10:17 Dan Carpenter [this message] 2018-05-30 10:17 ` [PATCH] drm/nouveau/core: ERR_PTR vs NULL bug in nvkm_engine_info() Dan Carpenter
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20180530101741.yht7j7zupb6btdvn@kili.mountain \ --to=dan.carpenter@oracle.com \ --cc=airlied-cv59FeDIM0c@public.gmane.org \ --cc=bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \ --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \ --cc=kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.