Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932133AbcJMMN1 (ORCPT ); Thu, 13 Oct 2016 08:13:27 -0400 Received: from mga11.intel.com ([192.55.52.93]:47979 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755391AbcJMMNP (ORCPT ); Thu, 13 Oct 2016 08:13:15 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,339,1473145200"; d="scan'208";a="772156220" From: Jani Nikula To: wharms@bfs.de, Dan Carpenter Cc: Daniel Vetter , Ville =?utf-8?B?U3lyasOkbMOk?= , David Airlie , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, drm-intel-fixes@lists.freedesktop.org Subject: Re: [patch] drm/i915: fix a read size argument In-Reply-To: <57FF5380.1080704@bfs.de> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20161013085508.GJ16198@mwanda> <57FF5380.1080704@bfs.de> Date: Thu, 13 Oct 2016 15:13:11 +0300 Message-ID: <87zim8wip4.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: 1863 Lines: 57 On Thu, 13 Oct 2016, walter harms wrote: > Am 13.10.2016 10:55, schrieb Dan Carpenter: >> We want to read 3 bytes here, but because the parenthesis are in the >> wrong place we instead read: >> >> sizeof(intel_dp->edp_dpcd) == sizeof(intel_dp->edp_dpcd) >> >> which is one byte. >> >> Fixes: fe5a66f91c88 ("drm/i915: Read PSR caps/intermediate freqs/etc. only once on eDP") >> Signed-off-by: Dan Carpenter Dan, good catch, thank you. Luckily we only really use the first byte currently... Cc: >> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c >> index 14a3cf0..ee8aa95 100644 >> --- a/drivers/gpu/drm/i915/intel_dp.c >> +++ b/drivers/gpu/drm/i915/intel_dp.c >> @@ -3551,8 +3551,8 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp) >> /* Read the eDP Display control capabilities registers */ >> if ((intel_dp->dpcd[DP_EDP_CONFIGURATION_CAP] & DP_DPCD_DISPLAY_CONTROL_CAPABLE) && >> drm_dp_dpcd_read(&intel_dp->aux, DP_EDP_DPCD_REV, >> - intel_dp->edp_dpcd, sizeof(intel_dp->edp_dpcd) == >> - sizeof(intel_dp->edp_dpcd))) >> + intel_dp->edp_dpcd, sizeof(intel_dp->edp_dpcd)) == >> + sizeof(intel_dp->edp_dpcd)) > > > > perhaps we can morph that into something more readable ? I would suggest: > > > if (intel_dp->dpcd[DP_EDP_CONFIGURATION_CAP] & DP_DPCD_DISPLAY_CONTROL_CAPABLE) > { > size_t size=sizeof(intel_dp->edp_dpcd); /* == EDP_DISPLAY_CTL_CAP_SIZE */ > int ret; > > ret=drm_dp_dpcd_read(&intel_dp->aux, DP_EDP_DPCD_REV,intel_dp->edp_dpcd,size); > > if (ret != size ) > ...... > > } > > this way it improves readability and reduces line length. Not convinced, let's just take the simple brace fix now. BR, Jani. -- Jani Nikula, Intel Open Source Technology Center