From patchwork Fri Oct 30 06:02:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1390823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=sOMRrw7W; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CMsFD5Mlqz9sRk; Fri, 30 Oct 2020 17:03:44 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1kYNVj-0008K0-KR; Fri, 30 Oct 2020 06:03:39 +0000 Received: from mail-pg1-f194.google.com ([209.85.215.194]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kYNVe-00085Q-U7 for kernel-team@lists.ubuntu.com; Fri, 30 Oct 2020 06:03:35 +0000 Received: by mail-pg1-f194.google.com with SMTP id t14so4328120pgg.1 for ; Thu, 29 Oct 2020 23:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=39TOTdTUWJ/LgGL/JNd/sqwP/NyoCorqNjG53R959BI=; b=sOMRrw7Wk5oJYxeMuGyl+aB83hmyOvkICLmGnVbnnToNnQ0ll75cIFUWsypGDAGrv8 Q5g47hsmayP4iB7rDKXsVxDO5vH0Ov8RYwqA7Yl4vXutu0poReeU75h3hxKrWBttnzZb 7oydElhoBQRHXafFGguIOq8Y1qpbI8hGBawtRiGPCLlZHVtrlL/082mC7waHb7JCKRRo d0jETvTu8uFY1AmH/LTC46T0UnMiXvYLsrrE2S6vWJDNf7WlgVhoZitqlBaoPpa7hStV 5R2bByljs6bsipmjIsVH/0l0NT79PHkBo48aASr2FCa3ZjdAheGdNVm7Af3iHEoQ++kS mnUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=39TOTdTUWJ/LgGL/JNd/sqwP/NyoCorqNjG53R959BI=; b=Lq438AeuP205CwoPIhgipWUgj8DUcqQfUkOXgSfXVIjNtNMq5PZAveHyMA9uk+djT8 ekUswSOGqMnds4A9p5OmKQWgm3bysor30AR74ttDsTlKX9PzMkNQ2lnwlMhSGB86Vh1q DskGNATW+KKkRPpNKjL2wMQoNgKXk97sV+heXcEMa9Ls+H1QbAmG1JB6VNgFzP/MIsno r1vQs2UBYQJ8U3mk2ccdZtpKBXX+jhiRgFoauQoYtmkBpWQZvmJQCi5b4rxtMeXV7oEm X5PBs8AfVk0nGBZOw1iH+3g6vg/Mxz5wJ9A9rfWdIqdyKMviDOwu8U3JlWqenemqZaf+ eliw== X-Gm-Message-State: AOAM532dakW47vITuACMWt0tDIo32lHbvd4PpjHUQw1oDYFNTcgOAtN4 hH5IhTKUxQUbXxTN4wqBrRUsljtB2oW1yQ== X-Google-Smtp-Source: ABdhPJxJNKYAVVOW3yWmu4QGSs4WTKDu7ln/oVbvouCiEokFjVSys77utv2U+3gX4r+zVwpl7ZTSFQ== X-Received: by 2002:a63:5b63:: with SMTP id l35mr896114pgm.70.1604037802952; Thu, 29 Oct 2020 23:03:22 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id t13sm4836557pfc.1.2020.10.29.23.03.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 23:03:22 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 20/23][SRU][OEM-5.6] platform/x86: intel_pmc_core: fix bound check in pmc_core_mphy_pg_show() Date: Fri, 30 Oct 2020 14:02:11 +0800 Message-Id: <20201030060214.780883-26-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201030060214.780883-1-acelan.kao@canonical.com> References: <20201030060214.780883-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.215.194; envelope-from=acelan@gmail.com; helo=mail-pg1-f194.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Gaurav Singh BugLink: https://bugs.launchpad.net/bugs/1899883 Check bounds before accessing map[] array. Signed-off-by: Gaurav Singh Signed-off-by: Andy Shevchenko (cherry picked from commit aff374dfe7330be10a20c97bd0b3196c153e9f9e) Signed-off-by: AceLan Kao --- drivers/platform/x86/intel_pmc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c index 5a0a25e9ccc9..338ea5222555 100644 --- a/drivers/platform/x86/intel_pmc_core.c +++ b/drivers/platform/x86/intel_pmc_core.c @@ -795,7 +795,7 @@ static int pmc_core_mphy_pg_show(struct seq_file *s, void *unused) msleep(10); val_high = pmc_core_reg_read(pmcdev, SPT_PMC_MFPMC_OFFSET); - for (index = 0; map[index].name && index < 8; index++) { + for (index = 0; index < 8 && map[index].name; index++) { seq_printf(s, "%-32s\tState: %s\n", map[index].name, map[index].bit_mask & val_low ? "Not power gated" :