[PATCH] nouveau: kfree() gracefully handles NULL pointers, testing is redundant

Jesper Juhl jj at chaosbits.net
Wed Mar 14 16:50:49 PDT 2012


Remove redundant NULL checks before kfree() in
drivers/gpu/drm/nouveau/nvc0_graph.c

Signed-off-by: Jesper Juhl <jj at chaosbits.net>
---
 drivers/gpu/drm/nouveau/nvc0_graph.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvc0_graph.c b/drivers/gpu/drm/nouveau/nvc0_graph.c
index 8ee3963..e9eca29 100644
--- a/drivers/gpu/drm/nouveau/nvc0_graph.c
+++ b/drivers/gpu/drm/nouveau/nvc0_graph.c
@@ -755,10 +755,8 @@ nvc0_graph_create_fw(struct drm_device *dev, const char *fwname,
 static void
 nvc0_graph_destroy_fw(struct nvc0_graph_fuc *fuc)
 {
-	if (fuc->data) {
-		kfree(fuc->data);
-		fuc->data = NULL;
-	}
+	kfree(fuc->data);
+	fuc->data = NULL;
 }
 
 static void
@@ -778,8 +776,7 @@ nvc0_graph_destroy(struct drm_device *dev, int engine)
 	nouveau_gpuobj_ref(NULL, &priv->unk4188b8);
 	nouveau_gpuobj_ref(NULL, &priv->unk4188b4);
 
-	if (priv->grctx_vals)
-		kfree(priv->grctx_vals);
+	kfree(priv->grctx_vals);
 
 	NVOBJ_ENGINE_DEL(dev, GR);
 	kfree(priv);
-- 
1.7.9.4


-- 
Jesper Juhl <jj at chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.



More information about the dri-devel mailing list