Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750872AbdHaGaU (ORCPT ); Thu, 31 Aug 2017 02:30:20 -0400 Received: from mga14.intel.com ([192.55.52.115]:53381 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbdHaGaS (ORCPT ); Thu, 31 Aug 2017 02:30:18 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,451,1498546800"; d="scan'208";a="895780866" From: Jani Nikula To: Himanshu Jha Cc: joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Himanshu Jha Subject: Re: [PATCH] drm/i915/opregion: Remove null check before kfree In-Reply-To: <1504099876-4142-1-git-send-email-himanshujha199640@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <1504099876-4142-1-git-send-email-himanshujha199640@gmail.com> Date: Thu, 31 Aug 2017 09:30:05 +0300 Message-ID: <87o9qw8d1u.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1060 Lines: 34 On Wed, 30 Aug 2017, Himanshu Jha wrote: > kfree on NULL pointer is a no-op and therefore checking is redundant. IMO the code has more clarity as it is. BR, Jani. > > Signed-off-by: Himanshu Jha > --- > drivers/gpu/drm/i915/intel_opregion.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c > index 98154ef..2427b40 100644 > --- a/drivers/gpu/drm/i915/intel_opregion.c > +++ b/drivers/gpu/drm/i915/intel_opregion.c > @@ -830,10 +830,8 @@ void intel_opregion_unregister(struct drm_i915_private *dev_priv) > memunmap(opregion->rvda); > opregion->rvda = NULL; > } > - if (opregion->vbt_firmware) { > - kfree(opregion->vbt_firmware); > - opregion->vbt_firmware = NULL; > - } > + kfree(opregion->vbt_firmware); > + opregion->vbt_firmware = NULL; > opregion->header = NULL; > opregion->acpi = NULL; > opregion->swsci = NULL; -- Jani Nikula, Intel Open Source Technology Center