Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1145681pxb; Thu, 19 Aug 2021 22:00:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAcUnuVh38Bnn6tNUx5RAUBsZHBnCViO/sHipz4nj9hsnzNI49A/uhHwHdkE+xqAxKBjOt X-Received: by 2002:a6b:6a14:: with SMTP id x20mr15221850iog.177.1629435629683; Thu, 19 Aug 2021 22:00:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629435629; cv=none; d=google.com; s=arc-20160816; b=zxxUfzQxA5AxSrUS+zyqxXh5Nt2FEungrSRFhVam61+Mx6gr+J6JnFOau8nyN2bU6a /xIZfYdmr9TvheTDA6XsRj02wve5JKFSj2m5F4kW5afhIXYM5b6ddQ9/FVRCyY/NbiH8 eQ5M9PGZFcwZE3srYFcGG2I1VA/vsWj86gBoYnxNrUKfjU8zO+VEDtFfEMgIY0p5T3T+ Q04xMO3A006moTVQFLdbtQsq8IiKodsEYf/RaApUhYBsbo/jbaBwedWYuDhvix421h2S CTatH5DhSPqWIhK63y9AUAtGN8i6W0+DBd3H773cwUjd2hEL1AK7fC369VlRWtEbfu2O tVVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0IUJB1GwObW9GeCFNTcimjHxXH16lfw5fqOn8ydUdKk=; b=JubOIKuSgtJ+6hJ2xJtQ0hdnv5sStqmFMYAWlYBpLamT8D0W64nbYtO7oL+dYrSwgT 2/KBCf9cvBLk5IFTikkNjFCZZIQNjlTARSHngex2yRe+qb/W8EGVo1mTzNyXM0EoD0kU Gpwmh+qlYw9rsnthPRtawn+QD4c1mg+rn1jabFMNoq/6Sl1mOYa4HrvuV7TJ4tMzYkm1 +IyThq2r64Hep4BpqybOROiIdwIowX1qwGugteN9w6f/jfe/+VgY8MWUHfHb5aGRSXUX Ry0YtuEwh9dNt70qLOs60xqzm4qnyzsEd1IeMQV4sgCVgGMRNSM4M5dNTcZagIu9EKAz qWxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b=ee+8LVSi; 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=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c19si5605402ilj.48.2021.08.19.22.00.03; Thu, 19 Aug 2021 22:00:29 -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; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b=ee+8LVSi; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234606AbhHTE7X (ORCPT + 99 others); Fri, 20 Aug 2021 00:59:23 -0400 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:43410 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbhHTE7T (ORCPT ); Fri, 20 Aug 2021 00:59:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1629435522; x=1660971522; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=AER5CHXg3NdjLXqRGWQm/QEcWLjWKJ+9+Fk2vCBGXzQ=; b=ee+8LVSiPW7uZdUhxNmWqsJDL+jnDx7B8PUgNoW38Biut+Mty5W27XWE QBsJUEVVLBSwLrQhrn3C1brvg7tcuxXhwjcLZWPSscQdxFX9QXIpXFFde bi3o5Uk4/msiZQAugYb032YisEwsEXHy6WlUhnPSvlYjc8jnK0d2+e1qP M=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-01.qualcomm.com with ESMTP; 19 Aug 2021 21:58:42 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2021 21:58:41 -0700 Received: from nalasex01c.na.qualcomm.com (10.47.97.35) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Thu, 19 Aug 2021 21:58:41 -0700 Received: from fenglinw-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.858.15; Thu, 19 Aug 2021 21:58:39 -0700 From: Fenglin Wu To: , , CC: , , Subject: [PATCH V1 3/9] spmi: pmic-arb: check apid against limits before calling irq handler Date: Fri, 20 Aug 2021 12:57:58 +0800 Message-ID: <1629435488-10228-4-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1629435488-10228-1-git-send-email-quic_fenglinw@quicinc.com> References: <1629435488-10228-1-git-send-email-quic_fenglinw@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanexm03h.na.qualcomm.com (10.85.0.50) To nalasex01c.na.qualcomm.com (10.47.97.35) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Collins Check that the apid for an SPMI interrupt falls between the min_apid and max_apid that can be handled by the APPS processor before invoking the per-apid interrupt handler: periph_interrupt(). This avoids an access violation in rare cases where the status bit is set for an interrupt that is not owned by the APPS processor. Signed-off-by: David Collins Signed-off-by: Fenglin Wu --- drivers/spmi/spmi-pmic-arb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c index 4d7ad004..c4adc06 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -535,6 +535,12 @@ static void pmic_arb_chained_irq(struct irq_desc *desc) id = ffs(status) - 1; status &= ~BIT(id); apid = id + i * 32; + if (apid < pmic_arb->min_apid + || apid > pmic_arb->max_apid) { + WARN_ONCE(true, "spurious spmi irq received for apid=%d\n", + apid); + continue; + } enable = readl_relaxed( ver_ops->acc_enable(pmic_arb, apid)); if (enable & SPMI_PIC_ACC_ENABLE_BIT) -- Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.