From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Carpenter Subject: Re: [Intel-gfx] [patch] drm/i915/gvt/kvmgt: remove some dead code Date: Tue, 7 Feb 2017 17:44:29 +0300 Message-ID: <20170207144429.GM11103@mwanda> References: <20170207131630.GA28207@mwanda> <1486478097.3121.120.camel@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Return-path: Content-Disposition: inline In-Reply-To: <1486478097.3121.120.camel@linux.intel.com> Sender: kernel-janitors-owner@vger.kernel.org To: Joonas Lahtinen Cc: Zhenyu Wang , Jike Song , David Airlie , intel-gfx@lists.freedesktop.org, kernel-janitors@vger.kernel.org, dri-devel@lists.freedesktop.org, Daniel Vetter , intel-gvt-dev@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Tue, Feb 07, 2017 at 04:34:57PM +0200, Joonas Lahtinen wrote: > On ti, 2017-02-07 at 16:16 +0300, Dan Carpenter wrote: > > If "caps.buf" is already NULL then it doesn't need to be freed or set to > > NULL. > > > > Signed-off-by: Dan Carpenter > > > > > @@ -965,11 +965,8 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, > >   sparse->areas[0].offset = > >   PAGE_ALIGN(vgpu_aperture_offset(vgpu)); > >   sparse->areas[0].size = vgpu_aperture_sz(vgpu); > > - if (!caps.buf) { > > Looking at the code around, the right thing would be to just remove the > negation? This currently seems like a memory leak. > > > - kfree(caps.buf); > > - caps.buf = NULL; > > + if (!caps.buf) > >   caps.size = 0; > > - } > > And quickly looking, the caps is pre-initialized but unused at this > point, so the whole if could just be removed, right? Hm... Duh. You're right. Let me resend. regards, dan carpenter