From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Subject: Re: [PATCH 12/25] drm/tegra: Use new drm_fb_helper functions Date: Tue, 14 Jul 2015 10:50:10 +0200 Message-ID: <20150714085009.GD12465@ulmo.nvidia.com> References: <1436769501-4105-1-git-send-email-architt@codeaurora.org> <1436769501-4105-13-git-send-email-architt@codeaurora.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rqzD5py0kzyFAOWN" Return-path: Received: from mail-pd0-f182.google.com ([209.85.192.182]:32868 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751848AbbGNIuQ (ORCPT ); Tue, 14 Jul 2015 04:50:16 -0400 Received: by pdbqm3 with SMTP id qm3so2458808pdb.0 for ; Tue, 14 Jul 2015 01:50:16 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1436769501-4105-13-git-send-email-architt@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org List-Id: linux-arm-msm@vger.kernel.org To: Archit Taneja Cc: dri-devel@lists.freedesktop.org, daniel@ffwll.ch, linux-arm-msm@vger.kernel.org, airlied@linux.ie, Terje =?utf-8?Q?Bergstr=C3=B6m?= , Stephen Warren --rqzD5py0kzyFAOWN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 13, 2015 at 12:08:08PM +0530, Archit Taneja wrote: [...] > diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c [...] > @@ -224,11 +224,11 @@ static int tegra_fbdev_probe(struct drm_fb_helper *= helper, > if (IS_ERR(bo)) > return PTR_ERR(bo); > =20 > - info =3D framebuffer_alloc(0, drm->dev); > - if (!info) { > + info =3D drm_fb_helper_alloc_fbi(helper); > + if (IS_ERR(info)) { > dev_err(drm->dev, "failed to allocate framebuffer info\n"); > - drm_gem_object_unreference_unlocked(&bo->gem); > - return -ENOMEM; > + err =3D PTR_ERR(info); > + goto gem_unref; > } > =20 > fbdev->fb =3D tegra_fb_alloc(drm, &cmd, &bo, 1); > @@ -236,7 +236,6 @@ static int tegra_fbdev_probe(struct drm_fb_helper *he= lper, > err =3D PTR_ERR(fbdev->fb); > dev_err(drm->dev, "failed to allocate DRM framebuffer: %d\n", > err); > - drm_gem_object_unreference_unlocked(&bo->gem); > goto release; > } > =20 > @@ -248,12 +247,6 @@ static int tegra_fbdev_probe(struct drm_fb_helper *h= elper, > info->flags =3D FBINFO_FLAG_DEFAULT; > info->fbops =3D &tegra_fb_ops; > =20 > - err =3D fb_alloc_cmap(&info->cmap, 256, 0); > - if (err < 0) { > - dev_err(drm->dev, "failed to allocate color map: %d\n", err); > - goto destroy; > - } > - > drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth); > drm_fb_helper_fill_var(info, helper, fb->width, fb->height); > =20 > @@ -282,7 +275,9 @@ destroy: > drm_framebuffer_unregister_private(fb); > tegra_fb_destroy(fb); > release: > - framebuffer_release(info); > + drm_fb_helper_release_fbi(helper); > +gem_unref: > + drm_gem_object_unreference_unlocked(&bo->gem); You can't do this. tegra_fb_alloc() takes ownership of the buffer, so unless you compensate for that (by taking an explicit reference to the buffer in tegra_fb_alloc()) you'd be dereferencing twice and likely end up with use-after-free errors later on. I'd prefer to keep the error clean up as it is. Thierry --rqzD5py0kzyFAOWN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJVpM0+AAoJEN0jrNd/PrOh2WEQAL1bmZCkzAhjr6fs/s/JgZHO NGU9N6R3vwETqM7AXCefXPWdGxms5jR6ouEGcKY0QbExoi27fzrljcPRIzRSvKEv UGdes71pwLOdpIAlwl6ycorbMe+FwHH1gxTJqVeqbV64XIlw3Lmxc9rjQckP7Q2c OWP3fGSkBvKW0nNIxKf2KI3Ue8xiR9xjRN2m1SLoo3SPjKvk8XKNYnzwODCv75Ul b1w+zmiNaKywXXBkBUhgFVm1vgk9TMZaDPOen/2uYI2TEywwJ4m1N/4RBI+89vpX YWqz15kSdanTCi/9cISaa4krJF8yVmJHrP/2Vr5+swoV2KfYktFFbolSZgYzEoUY 7hL4OEhqiwM7q23Zna0x5EwE75J2vbDlo5k9+rpOJt7pwJxaNYdj1FS/cPpftO4C 6Pb923kORl86SUM9ZU6B45KTM4CFrr5PrpD843cjTV/o9yGG7ukm6LQiDAyQWSox frBFvWt/gzrM+f6Z9SJsBJsDLXxFFMHOaSckKD8RQE5ywfHx5PRS88Gd8E58siy+ RSUKNFYTOE3PEUNBRP2k1jMK5yunbnNyugm3HYkVoUF084eYEORZi3dOFYNqJavx qppuPcv/a7KxDGYtIGYvtwDIxWbWEFVz4DbaKEYVxFklH/FclJeG1gxD4YMkJ/oZ xKBTtkVYGvWyWcdvmErs =Ohce -----END PGP SIGNATURE----- --rqzD5py0kzyFAOWN--