Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1568940ybt; Thu, 9 Jul 2020 10:02:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVWnLHTy1oSB00NcyO1MQ5EgZv7X/aImDexp27RUtB3jriSng+Gf/YugkmJUSF5RiJCELA X-Received: by 2002:a17:906:2ccf:: with SMTP id r15mr59571312ejr.277.1594314135682; Thu, 09 Jul 2020 10:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594314135; cv=none; d=google.com; s=arc-20160816; b=nmak3EN06fFk98AFrF8SxpNcrKgM/bo7dsQNuXpuRs9roGGaXy/7FbrRORgBrDZhmk 9xRzCZyk+TtXttSvD5iCUdxiVtAU8APFf+OPTuIRsCH9oI+Z7aiUSMj1G7SbJADzoYMe Ealxd93k+XaCVpQH3/SRZfnzo7/VxjgRxdkU/Bh816k4Bh0acbrM6LtY76OPyOj0sMc6 X16pOTA8I+l2PkxQR8H3Ayv/OCcYpUXp5bLgEhIQKdjlz3foKQ5yN6cMOZP/I0sq8gyd ANTat6OfDBy8Pp37QqdyFlMClZa3VbnjlSFwfg+5l38COuS26oJaSAUYQWd5VwaNsrAz htKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:ironport-sdr:ironport-sdr; bh=YZm82WXsf6PIC3c6hD0NMzbuGPeQUCOQWLzsfAiK4gw=; b=udAsM9WHwa4Zku3fHjvSRcJA+/DJfm+mJsGquixJIVzbqAU8Vb6WFIYICx7Yf+MIYZ UM8R3UQzrzVyZYPmkt9n5q7PvRs+R1BFVO9HeFEsW0EDWQ82pYaynGx4s+Il80hLLs7E 8PmJZDh3l5xkAjSvIcYmOPZliyS/Y/Yc9rdDQAd8EQzGbr7Ozb6bLz4gidVSbPbF9V8D 0bJRkgAzO9C4h1uNmVLuN0X0hWeu8COtRthMwPMp8TeVEBvZZCPE+2RonS+ILKZOOQc3 vruyyqZsIjjfq1afGyevKbhDz0x3LRlx8MuXUzamXZK7dtIz0g/+ZzgHGz0voYZE3zRm lXIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t24si2433175eds.158.2020.07.09.10.01.51; Thu, 09 Jul 2020 10:02:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727768AbgGIRAw (ORCPT + 99 others); Thu, 9 Jul 2020 13:00:52 -0400 Received: from mga05.intel.com ([192.55.52.43]:47626 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726722AbgGIRAv (ORCPT ); Thu, 9 Jul 2020 13:00:51 -0400 IronPort-SDR: pr92ZLzmvhfdbO0gLPdzqeZmKfxerIjCoPMVTyGzZsJhMmPV48bk6D8x0ndGOSiLQh+9xS2AqJ wXwCogQS5bdA== X-IronPort-AV: E=McAfee;i="6000,8403,9677"; a="232915650" X-IronPort-AV: E=Sophos;i="5.75,332,1589266800"; d="scan'208";a="232915650" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2020 10:00:46 -0700 IronPort-SDR: ReqF61yT9GNlrJ2FoKQId9/N0nD7svQY92hCP2NuekQC6dLMzXqDS8Zi+SwBTQPG+D9Hk3HL9p qoxFDAc9sRGw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,332,1589266800"; d="scan'208";a="457976840" Received: from rpantang-mobl.amr.corp.intel.com ([10.212.22.171]) by orsmga005.jf.intel.com with ESMTP; 09 Jul 2020 10:00:44 -0700 Message-ID: Subject: Re: [PATCH] thermal/int340x_thermal: Prevent page fault on .set_mode() op From: Srinivas Pandruvada To: Bartosz Szczepanek , Matthew Garrett , Zhang Rui , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Lezcano , Amit Kucheria , Radoslaw Biernacki , Alex Levin Date: Thu, 09 Jul 2020 10:00:43 -0700 In-Reply-To: <20200708134613.131555-1-bsz@semihalf.com> References: <20200708134613.131555-1-bsz@semihalf.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.3 (3.34.3-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-07-08 at 15:46 +0200, Bartosz Szczepanek wrote: > Starting from commit "thermal/int340x_thermal: Don't require IDSP to > exist", priv->current_uuid_index is initialized to -1. This value may > be passed to int3400_thermal_run_osc() from int3400_thermal_set_mode, > contributing to page fault when accessing int3400_thermal_uuids array > at index -1. > > This commit adds a check on uuid value to int3400_thermal_run_osc. > > Signed-off-by: Bartosz Szczepanek Reviewed-by: Pandruvada, Srinivas > --- > drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c > b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c > index 0b3a62655843..12448ccd27f1 100644 > --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c > +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c > @@ -216,11 +216,16 @@ static int int3400_thermal_run_osc(acpi_handle > handle, > acpi_status status; > int result = 0; > struct acpi_osc_context context = { > - .uuid_str = int3400_thermal_uuids[uuid], > + .uuid_str = NULL, > .rev = 1, > .cap.length = 8, > }; > > + if (uuid < 0 || uuid >= INT3400_THERMAL_MAXIMUM_UUID) > + return -EINVAL; > + > + context.uuid_str = int3400_thermal_uuids[uuid]; > + > buf[OSC_QUERY_DWORD] = 0; > buf[OSC_SUPPORT_DWORD] = enable; >