From patchwork Wed May 2 01:10:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134812 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp125553lji; Tue, 1 May 2018 18:13:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZojj6XhZDe22vXOqrrPztfRhLeA6gU9yu/9/e3jw3cZhbdUeACsbrDvk3YMVH6YIf6WhaKZ X-Received: by 2002:a17:902:1744:: with SMTP id i62-v6mr18356675pli.267.1525223587934; Tue, 01 May 2018 18:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223587; cv=none; d=google.com; s=arc-20160816; b=BRih+B6S0e3z5ijpuZlnZ+j2SDWNkQuHKXFokIKoZb5ObaC6WsLjJPCiXytJgOw4l9 fr9ZGUs8+Tq5YuWApCyO2w3MHK0l8FvFowHBXiSBgIYhxqk6hUPCOAK6DkAfai8kOrUW hwDOqJUX+xyWUltbz/bHAv+TowL9X87R/aZR7dEr8HxeDa+U5ALG2pqPXGi2nCH/3dW2 pAhsiFD0vgA4NRg+LVaWLaLpCmvpeZSSqMgxFLt3AwY+Jq3kaTgXboGEY+NIjSFLQm+O JvbcqXauNWHDRgZsPbgSdEupu51tyy3f8PYXrnjFXwhQJeTTWePyl1F7aeDWiMP6R74p x0pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=1RXDSFOq1f1QYWFkcgyfUNldmkjn1WJSH/OCHWOfUjs=; b=ggDRJybYVNzkWLUb679siioczg6xGhaksj9P6V2VYo9HTaGh2Sakww02Wvo8hOi7vs lTxp6LB0WDelpknhdL4oKLADU4wcTSU/03D02Be02afousVeURj8PBZ45kd0n8YC2D9s TIOgeD69ol+5aroUsfEznmI/6R1jNbWNoKkb3caBAWqBVZYBlZRQ/u9K03UI34eeb3h8 ZNio+DxOBibNlrLpY3A/aOQ4pUCFd2OCCYTxPYWeJc+ueXVQpZtDyblwicuL5l8xqnDY AlWH1EfWvcy7A+Rko3d8wlOVoAi61391t/S5zDBDzmnxUG8+hv4PhG/QjcmjxoU+S54t L2pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jkA1uNbF; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h61-v6si10141052pld.228.2018.05.01.18.13.07; Tue, 01 May 2018 18:13:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jkA1uNbF; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751455AbeEBBNG (ORCPT + 12 others); Tue, 1 May 2018 21:13:06 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:34646 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751029AbeEBBKa (ORCPT ); Tue, 1 May 2018 21:10:30 -0400 Received: by mail-io0-f194.google.com with SMTP id p124-v6so15604253iod.1 for ; Tue, 01 May 2018 18:10:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZZzu3l8jcgZvq4ndJoB14BgCndafFixyKtg8Nan0A8g=; b=jkA1uNbFxd+k5Wsc3tstDS1Ky2VRlQZqz3G4X9V+ABDrK0iB/UuDcbLsTTKTYmmtuq JrIwYAmXTCIU6+CtghUv7k7ndrjUPepkPgj2TIQmPkjIbTDBmXLmH0SmKQDgrHfyhBg9 UdBTnCpGqX4Sp63/JXmVXvDXak0TohX+JbTg0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZZzu3l8jcgZvq4ndJoB14BgCndafFixyKtg8Nan0A8g=; b=L5ZLOdcOlY+UX+O1d4eiPwQsotqTQ7gleUIBdo5co2B7sywV4MWEOkZzuBiTixsa5b UrjqhAER0h2642tvYEqt5EtmTPtyvE/njYwooeJfCUFOn5PDnkkm0xKavRlC35sAllfn lkDJ8e0JEzGeERsyF8zWemKVtr9s0nJlN5VV7cY4+3vurpU40iFSMp8FGak7eNXyfJww ko6oHygMlMsTYxfXjZ6xNPfqDbG5lH2YTnUxSxhSro9a6pZsJea2VejfdaY+3dmfvtT3 47Ox0F9AAtcZQlZrwFMIdrsAGAYCE8LI1VxJ2+XmnVeMEUw5UVEz2CntNSCGJxstW0nM GpEA== X-Gm-Message-State: ALQs6tC8P3+7ly2ODjhnMq80O9QE5fFxCj1ScJ9mcIigO6NqSDxDXAmL bXVsIg51cjBp7rXWJHH7Gohbtg== X-Received: by 2002:a6b:298f:: with SMTP id p137-v6mr19516412iop.288.1525223429668; Tue, 01 May 2018 18:10:29 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:28 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/12] soc: qcom: smem: initialize region struct only when successful Date: Tue, 1 May 2018 20:10:09 -0500 Message-Id: <20180502011019.22812-3-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Hold off initializing anything for the array entry representing a memory region in qcom_smem_map_memory() until we know we've successfully mapped it. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index c46bb43c0f3d..d8008bf480a4 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -887,6 +887,7 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev, { struct device_node *np; struct resource r; + resource_size_t size; int ret; np = of_parse_phandle(dev->of_node, name, 0); @@ -899,12 +900,13 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev, of_node_put(np); if (ret) return ret; + size = resource_size(&r); - smem->regions[i].aux_base = (u32)r.start; - smem->regions[i].size = resource_size(&r); - smem->regions[i].virt_base = devm_ioremap_wc(dev, r.start, resource_size(&r)); + smem->regions[i].virt_base = devm_ioremap_wc(dev, r.start, size); if (!smem->regions[i].virt_base) return -ENOMEM; + smem->regions[i].aux_base = (u32)r.start; + smem->regions[i].size = size; return 0; } From patchwork Wed May 2 01:10:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134811 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp125224lji; Tue, 1 May 2018 18:12:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoKQuiul30w7OgyCUcUpjz1mj79XVYjfk/r75j+0QtJGXv40USBxf4Wdy85jKw1FL0RD+4f X-Received: by 2002:a63:6ec7:: with SMTP id j190-v6mr14326866pgc.71.1525223560765; Tue, 01 May 2018 18:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223560; cv=none; d=google.com; s=arc-20160816; b=UCvdxKS1Rfb/6eokXwvxRCvVAH+wggBTRt/ipjecV/sr7cTFZ8zihgYg4UGaY7Gael kqXBsFlJkLai4lek32+6MOT/n/TabD3IiiDmMHYHe5NjbiXR+lb2QFxHSavOBfGZcpAf a/ca7fdkPuMY9Lg6Vh48sRz6BGaI/TWW4xoftj6dfNltNvj11qVESy+Y05APGGpQkgw3 9IVy8v2LFb6HMCio8Lczybhz+q94i+9YqAMlPkDxwYlDZaYNqgM3lLRHZxXKdwVQHqlw jICqWIiZOp2fl18rw+1qG8+CNjULT5ZpMQV7FBeghBXPPFRDTEijpFfW/5VUoeqEbKy1 1Lsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=rUsjSto+doHhw2ElZggGnYookdq0o1rpr+mtuYUM2IY=; b=oYypZRGBn1CwZ/kqbbdG/51ZBxyDHibCdqCVeBHGeU27wd69drTYI5arR3WYUySB0n YsfSbHzKb+5HDRpmuTBKeIJ6Bj+UOfi2oXN62egZlTxwPblE9F1UkAvRmI3S9ml9pJyT 2/vXvQXvLXAjkF0x1BqNqbIT15TXW7L2hlNfSUEIhU3WZWaeYmpWy9JQz17ISIWiZEOX FjYCCQetq9Pg89k5gv2psBvWUGG4+wy+ZW9cIDtd+4CBff8ai2s4rT1CQlWLNyZvs9J9 +4BkM+qm0aqtZLwtTS/laUE6tL7VPp84UDhXLOVLz1+jb6eQsgnJXxXhofXpITBYgEhR PYfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RJSb10vo; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c24-v6si9047045plo.489.2018.05.01.18.12.40; Tue, 01 May 2018 18:12:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RJSb10vo; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751167AbeEBBMi (ORCPT + 12 others); Tue, 1 May 2018 21:12:38 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:42382 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751186AbeEBBKd (ORCPT ); Tue, 1 May 2018 21:10:33 -0400 Received: by mail-io0-f196.google.com with SMTP id a10-v6so15576656ioc.9 for ; Tue, 01 May 2018 18:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+lEtxFJLX+XM1onKl5Obo+Yr4L4/r5icl+NOTkGiYUA=; b=RJSb10voUscmHHOSRmNi1f0xKOeNcVDRZbQVzW5FtK5z+BSV8eE6ibOWk/E1rz4I1Q PLZ8XsN8UaAkd1qIpfKLxBqy7PjCfO0W3kdOz9NJIKcbN5FMeDv/ERmNUDzad37wc/es hIZyvYU6Fl4vnE4Rt0HLDCx0q17OE71gCGNbA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+lEtxFJLX+XM1onKl5Obo+Yr4L4/r5icl+NOTkGiYUA=; b=OQmrlFZrn+jGlehFgDYQP1BXiPVYlzbPWNRWXiUR1G6nQ8TbWrFBUFkAS0vgrkVXOD dM+corT+LfTkZQJU7qml+XFMuLAskvKdaDtJfzjeMqR/SxCSMhTz5khszKx2KoF2tJ1/ Ib+kzB5IhH44aN0Gs/MI+8HdD0yokcTaqR3Jn/s3+5gjq3bBkrTQcWzmGO2nkclfNbRE YfzhTc8+lEmjaytVYloz7I8Ms01qyr5bY16a0XSWGq21tYaNYSEzzX0l/mXcTXGcB5kU BMV5tRtvtgICnMMRGa9kbEI2ZaJSgOz1yDiZDkEfFgnnN2fjXOh3efVU+vS0yVp/1oY7 VlYA== X-Gm-Message-State: ALQs6tDPzF9YIhvTJr3bM+Vu+P3eFC3knIm0ZKkE7b7+MiteLfVMlyhh DvPYbJHJbhAl84bKCsNVo+lq8Q== X-Received: by 2002:a6b:88d:: with SMTP id h13-v6mr17876217ioi.43.1525223432660; Tue, 01 May 2018 18:10:32 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:32 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/12] soc: qcom: smem: verify both host ids in partition header Date: Tue, 1 May 2018 20:10:12 -0500 Message-Id: <20180502011019.22812-6-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The global partition is indicated by having both host values in its table of contents entry equal SMEM_GLOBAL_HOST=0xfffe. In qcom_smem_set_global_partition(), we check whether the header structure at the beginning of the partition contains that host value, but the check only verifies *one* of them. Change the check so the partition header must have SMEM_GLOBAL_HOST for *both* its host fields. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 5d3ed510e54b..6931602d9a9e 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -769,7 +769,7 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - if (host0 != SMEM_GLOBAL_HOST && host1 != SMEM_GLOBAL_HOST) { + if (host0 != SMEM_GLOBAL_HOST || host1 != SMEM_GLOBAL_HOST) { dev_err(smem->dev, "Global partition hosts are invalid\n"); return -EINVAL; } From patchwork Wed May 2 01:10:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134810 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp125198lji; Tue, 1 May 2018 18:12:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpobZF+RWXmErSiy+VMOgyJR17P4iL2jDDp35k/QJiH/eaV6l2CtEIZYsSxvuBM0czBub+x X-Received: by 2002:a17:902:1aa:: with SMTP id b39-v6mr18239150plb.120.1525223558322; Tue, 01 May 2018 18:12:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223558; cv=none; d=google.com; s=arc-20160816; b=izKDfzl9ibEbwSvzHQkX2flHSvX6LTfDaPS8+mkHyusWErQl6gb8aP26OfhDGRQBt+ 8TOtz+oLDmic41ecag1iNI3lcW/gPu3+7chNBcSoThVVbJJe1OWbxJq+HPHpN5by8VLW zQy0qcL/u32+3/UlUkaw1XTFtc1Ix0leRF2+1x1WeZ9qAfycbV726Jln3RJ02QI3qKoy 8T24vTrEKDNkqMsXmXr9o+bHb1GzYlVuOKnHnh+E8EbUcRn5i0f2XcQ5PuOcyz2Tg7Ms Xzr95+PL3HiRqANEzNEok2ckdHUGzS5yXSebdyE7cl302TdLJ5aS+NQ0hZPHCRNgs81k yhTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=IdSl50omWtYej1ikEs1qAoQdyCx+OO3AzPCgn0d1k2o=; b=RrreP66c8QNrBxXhEVspMF7VnimAosuGfQXeC6c31oRhSim8UQAvYwbDQBJUCJfPcO aTNJddblua/V5M6NdlhvC293OJQeq5J2OTxOl154rGxKoXtidqaPRFELVx0hgThjZ9E0 pZIQbpi97BY/mxSMNnC0TBgnzolsorgqVgXVjWDcYK9v41Gk8F9DZXXJKmhyMvrCbsFd KPdI2tqRwfMsBVZxB9N9ba48cEmpN1m9dfY9+QRVPAQIKHAiQaD6bBi1sKxidPFJqheN aebvHFmxe26qRyzRxFEmr4ddD+pBvqUgnmLEDZuKSpanmgt4BeIJRrGxMHJeofzpfyZY SXiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fsqzvjOu; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t6-v6si8600322pgb.653.2018.05.01.18.12.38; Tue, 01 May 2018 18:12:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fsqzvjOu; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751181AbeEBBMg (ORCPT + 12 others); Tue, 1 May 2018 21:12:36 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:38030 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751195AbeEBBKe (ORCPT ); Tue, 1 May 2018 21:10:34 -0400 Received: by mail-io0-f195.google.com with SMTP id z4-v6so15595728iof.5 for ; Tue, 01 May 2018 18:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UVWwEuHQb/yiXjklaLkSaRYhXnA5qN9FoT/oKz31gcY=; b=fsqzvjOuhJIqfnmPXqmRRARrl0Y7j7fKraDtJUqjWtgp0EFAji8+jpKpU+piPKh9Og KbKTjW5RThB7pQmH4Qj2Lxhz7s2xjeUIrAz/yvOKt7GfUijKwwD3TFVUmXv2dLtAJcXj /JCs4yUCZxiKaFmRhmJxBkdRMnW+73QnTaFHU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UVWwEuHQb/yiXjklaLkSaRYhXnA5qN9FoT/oKz31gcY=; b=InbnT/C7FCznzDoOKLnOLSp0yoJAubqQt+IRI2z1RL8XYjSDyrelf/9CpzjaTCBb9S 7cD7Mix4WG3/gncYYMqb1exclnLDieu/8iJg+MizmVJ8wqIyixhThaG2t/XrQ+kyl1Gq jL+uQi3fseXydv/j0Ah8hsPMZVgzOlffMIZ/MsaqAz+SFZgbPqwCqfiB+qGGyuxImdqr w+TUikOgyeknqFjGRMkB5HRRWSFr1KOdeYc6kaoO31r2pDZ3Ur1V82SmoWhrYK5LMP1p zCubkDeJccaoJpFmOfJhf9IJNlMRoQrnUStKzewyPRkL0tEtoXCI3yXaLtYTKmNxqcpR 1IFQ== X-Gm-Message-State: ALQs6tDc1Exen79uV6Moobvt1v0azqpcuHDBXzhcktXuTztihj1Ib4nY fDwR3zijmrve8p2w1zdUTD4x+g== X-Received: by 2002:a6b:821e:: with SMTP id e30-v6mr18113918iod.264.1525223433625; Tue, 01 May 2018 18:10:33 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:33 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/12] soc: qcom: smem: require order of host ids to match Date: Tue, 1 May 2018 20:10:13 -0500 Message-Id: <20180502011019.22812-7-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In qcom_smem_enumerate_partitions(), we find all partitions that have a given local host id in either its host0 or its host1 field in the partition table entry. We then verify that the header structure at the start of each partition also contains the same two host ids as is found in the table of contents. There is no requirement that the order of the two host ids be the same in the table of contents and in the partition header. This patch changes that, requiring host0 to in the partition table entry to equal host0 in the partition header structure (and similar for the host1 values). Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 6931602d9a9e..9e20c6b1b4c2 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -837,9 +837,6 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, } header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); - host0 = le16_to_cpu(header->host0); - host1 = le16_to_cpu(header->host1); - if (memcmp(header->magic, SMEM_PART_MAGIC, sizeof(header->magic))) { dev_err(smem->dev, @@ -847,15 +844,10 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, return -EINVAL; } - if (host0 != local_host && host1 != local_host) { + if (host0 != le16_to_cpu(header->host0) || + host1 != le16_to_cpu(header->host1)) { dev_err(smem->dev, - "Partition %d hosts are invalid\n", i); - return -EINVAL; - } - - if (host0 != remote_host && host1 != remote_host) { - dev_err(smem->dev, - "Partition %d hosts are invalid\n", i); + "Partition %d hosts don't match\n", i); return -EINVAL; } From patchwork Wed May 2 01:10:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134808 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp124777lji; Tue, 1 May 2018 18:12:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoK615oLtYovYqUmwH+4wRYS5OHFXY7hGMd4gGxWOv+m75mWBmZOmg1fDoh7VqoKC6gdKZR X-Received: by 10.98.5.129 with SMTP id 123mr4571230pff.38.1525223522327; Tue, 01 May 2018 18:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223522; cv=none; d=google.com; s=arc-20160816; b=1LgbreD/hEEaAwS3RoaLjMhfDWWV5q2/Oyg5EsfzqrK6+JBHKjg+gduTu/QbXHbqF3 74QM0/jB6aiaBPIEbKXnSKJQEVR2IxljbnJ0k9kNVgRehxlVuoCGRqWM091FITM6Qjif 9VpRAcgjrRI3gzQKPjvF5Kk45BbhgTbylAcBaiiU4xNtoN31kHjgRlgZYzLJWPpdU6mM O0xh/ME66GvF2PKF6Bjody55fJxufphK+M2fmRcNxTAF2qtF2goaY/5wq7V1VuX52pb3 ahEiO3JQQ4ugwI/UJX2PwlFAid+1Tn5XF2rN+GJ5VwKb6ZmDbHnfg8aZddCfpR8DgCiE k8Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=uyakRVK7vDwBd8ZUkx+oD5IGmu2GNBCkxcCABF4tKFQ=; b=cL5xf/XpGC82Y/5qI8X6aMtZF9Nu9YbtjeL73G0DbXh367WpqUfOAFK0pWakrFd9Ol F12npULJrdlseszpniYpe1qbHcxZWWD2EHPPjVmvzQQIIW6fZlCXXHa2ZRK6eaJPOQKM Rdls9GWZcRtb3dnn9pNVWNQY/uzgA1Az3AqYKstxhmMLo9rZqSMtdqqey1I89FLw3Xva AmfBaG3riXLbOxK1jtlyznKwlVpohj6R1Ref88jcXvarYzhMbhWh+BGR+1lNUQOENV3q KYt37PP5LMUCqhnqciYRoQRrRtKzrZ9z/kJQ5KW0t3H7OJQlAZMtFWcs0cwVIS+i/+lw nZvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fTH6T3RP; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9-v6si4495461plk.94.2018.05.01.18.12.02; Tue, 01 May 2018 18:12:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fTH6T3RP; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751505AbeEBBL6 (ORCPT + 12 others); Tue, 1 May 2018 21:11:58 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:35487 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751241AbeEBBKf (ORCPT ); Tue, 1 May 2018 21:10:35 -0400 Received: by mail-io0-f193.google.com with SMTP id g1-v6so6230995iob.2 for ; Tue, 01 May 2018 18:10:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LbahlbqXD+qJbEDg3ue3is5H4Ih6/uAkLwNI1Dv8cl4=; b=fTH6T3RPLR+TjZL+EdoO42NXQBr0OpNpY4lAMoYSVsSk89Z/9FtP4KyMQxUrPPHHP+ Sb7/kFBTy68dJfZYN/BLhhErAj8pknJ5S8nLjYk0HGRO4CuEz9+FU7Gt6cK9zK2s9ETg XGtheaaocQIBnRDkWx/kDqZvnwethUtBBIzh4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LbahlbqXD+qJbEDg3ue3is5H4Ih6/uAkLwNI1Dv8cl4=; b=lP5z/hwZ3R/XVb6JiE2EP2jYNebYJOAD0KljlNChtKUeQHjUHZAD0RvTHTFLhPVBcX yQ4haqhCMjqjBZEqKYAYuf9vXa6rMYydwntBLBxVJct2u61nDt+REHtjlJc4htq8oPgn sQX+HtIWTyYAVTfN4bMb8rAAtebemJGghDNUcESu2y8gORrD48vLazy4QUSAGN06Ofe2 PwVbvxyYftfV99XVsRrhLkP1K2mMdLALtKz7IUPHwkPhddOK1hvy13c+1IxPFxc2UoWF Zx+m2s9KJAlmdx05A0mejD3owY1IRA2cq6mZAZn+d7/4tm0ECuogK8Sv3TnvY6BNqqWb EE4Q== X-Gm-Message-State: ALQs6tD/HL7QFqS6YWNTeBSNSwxctKK+As7mLrWmMW/Fe1swcArj5Yze 0tf3K8daPwjA3D94DoHJTdl6CA== X-Received: by 2002:a6b:8b58:: with SMTP id n85-v6mr18172296iod.109.1525223434584; Tue, 01 May 2018 18:10:34 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:34 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/12] soc: qcom: smem: introduce qcom_smem_partition_header() Date: Tue, 1 May 2018 20:10:14 -0500 Message-Id: <20180502011019.22812-8-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Create a new function qcom_smem_partition_header() to encapsulate validating the header information found in a partition. This will be built up over a few commits to make it more obvious how the common function is replacing duplicated code elsewhere. Initially it just verifies the header has the right magic number. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 9e20c6b1b4c2..d52a282f7338 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -727,6 +727,29 @@ static u32 qcom_smem_get_item_count(struct qcom_smem *smem) return le16_to_cpu(info->num_items); } +/* + * Validate the partition header for a partition whose partition + * table entry is supplied. Returns a pointer to its header if + * valid, or a null pointer otherwise. + */ +static struct smem_partition_header * +qcom_smem_partition_header(struct qcom_smem *smem, + struct smem_ptable_entry *entry) +{ + struct smem_partition_header *header; + + header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); + + if (memcmp(header->magic, SMEM_PART_MAGIC, sizeof(header->magic))) { + dev_err(smem->dev, "bad partition magic %02x %02x %02x %02x\n", + header->magic[0], header->magic[1], + header->magic[2], header->magic[3]); + return NULL; + } + + return header; +} + static int qcom_smem_set_global_partition(struct qcom_smem *smem) { struct smem_partition_header *header; @@ -760,15 +783,13 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); + header = qcom_smem_partition_header(smem, entry); + if (!header) + return -EINVAL; + host0 = le16_to_cpu(header->host0); host1 = le16_to_cpu(header->host1); - if (memcmp(header->magic, SMEM_PART_MAGIC, sizeof(header->magic))) { - dev_err(smem->dev, "Global partition has invalid magic\n"); - return -EINVAL; - } - if (host0 != SMEM_GLOBAL_HOST || host1 != SMEM_GLOBAL_HOST) { dev_err(smem->dev, "Global partition hosts are invalid\n"); return -EINVAL; @@ -836,13 +857,9 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, return -EINVAL; } - header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); - if (memcmp(header->magic, SMEM_PART_MAGIC, - sizeof(header->magic))) { - dev_err(smem->dev, - "Partition %d has invalid magic\n", i); + header = qcom_smem_partition_header(smem, entry); + if (!header) return -EINVAL; - } if (host0 != le16_to_cpu(header->host0) || host1 != le16_to_cpu(header->host1)) { From patchwork Wed May 2 01:10:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134804 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp124043lji; Tue, 1 May 2018 18:10:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqCHQlKGtKYVSSTJMhOoIPp75eCkb9mS9BjcfrQvRdVsy65mdJXlBn/rEUPnfIffdLPY9dF X-Received: by 2002:a63:351:: with SMTP id 78-v6mr14943649pgd.355.1525223457094; Tue, 01 May 2018 18:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223457; cv=none; d=google.com; s=arc-20160816; b=lhGP9RcrRLxamh0XHE4YGDF0hE0wZtCaHgz8YOWI2Gp6z7K0YRQ+HKJQ9RBqvbN5qq buBYCGbgjKIFoB18l1UapGzccNEeI95KA6AvRrrwruJL+gM+ER+b7rgef50FE1pwQjMA TnnVrXjxd2Ix6r4u/n6uFXZ+WlEiUmpBwoAqWJa547e+NTch6tP74J/7ZlxL2ChxONLk KqjHkX2MzFeWDigZON4/toFxuGODhgqIov6Lrhk+EsHjFNxPOm3VxzWB8gXCcB69BBb6 dciBKgv0BHECGvg8PraQ6zbBFPf0H9+haIdLXotWFYiMUOV7b83YYCLFo+lJthwTnpTW gfLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=vP6QVy68RbIPBEiVACmjoUfOubU/kqO2H87ExNDdRRc=; b=N6qg1rmdqR2qwWuYL2FunDL37kwJdc6IDhVKca/UTE9b6sradWaept1fMfdpvaHH6D GWNMwg0QWal3tTWYr1z0o2Fkf9jXFNBpr3+mmQkXYK6p1crzqpnU0vXLQGAwdDRuqMtO IXNaxF4fnkVBI/dTQSIzCCn0PPYgALtTzGhNV5kglXVoE4uaHXdYIgZYxVHWJ0L0cygH wBLZY5wBK33kleSVdIU3KcIDUDGM87DxHcGqAeBdWbTFKraW41/wrhkK2dOvanKNEDMB 2KTuk6gPzWcUF0irZYsvv1+Hcso58SnLzDR2X9mtwy/sNQaH91YEJ+Sh4SZT+WmZngZC YvOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GhzQXFfL; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10-v6si10789274plb.272.2018.05.01.18.10.56; Tue, 01 May 2018 18:10:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GhzQXFfL; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751178AbeEBBKz (ORCPT + 12 others); Tue, 1 May 2018 21:10:55 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:34797 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751331AbeEBBKk (ORCPT ); Tue, 1 May 2018 21:10:40 -0400 Received: by mail-it0-f68.google.com with SMTP id c5-v6so12733248itj.1 for ; Tue, 01 May 2018 18:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n/InIgNz2kBb8f3oYAThZXz24YW3M0BOUr4CeynODvU=; b=GhzQXFfLOfvvulRxcoOrr4WSjz43kpueCVRD1gWHqn4ZuBnxM5348SsOWLECyCH9wP R2zoxO6zguIMGlWoxRmNAbAddD6vMjW55FZKFmOCkxJ5pZqJv6h6pHpPqIX978cpe8ys 5VOkThkpLDcTXCDgm1eanurkLtertS3PzZUPo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n/InIgNz2kBb8f3oYAThZXz24YW3M0BOUr4CeynODvU=; b=uAWd/UHUJbVZvh78v04m1ZnZNZPsYrPXIdReyHXUZE1+aoXhsS1kBNNBrvMwFHjwkj Rk2r8ke/EAnFBiQ5QQ+EmI4Ma0rqaMGpFeXjKu4YUMWLhUF7kH9fS7tYknxe4rJPI2dv VMq7ccueUHZdsdumGYO46ec17KTFe0ApzCC/gtVJCXKuly6tQyIMCz5t9fOqAQTaRki/ Uat2sEIM0bCz8WiqjX4iaqoWhF0cSWK9Ix/tamE9go2uxcFxBYnW3REs3UohTlGna3dh Roi5fR7Sm3F2OvpWvfyQj/wX5xZ4QNU92qosUb6vNR+t7hmI3UwI0mA6TRfzFpSngx5J rlkw== X-Gm-Message-State: ALQs6tBbI8NLfxMhpaLnWG9uSY6nyFAWGyb9CQPZ4K9VzihFqmJixf9R Yw18YbofxK3z+kUbGyAyyqPbXw== X-Received: by 2002:a24:a74a:: with SMTP id s10-v6mr6005936iti.92.1525223439501; Tue, 01 May 2018 18:10:39 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:39 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/12] soc: qcom: smem: a few last cleanups Date: Tue, 1 May 2018 20:10:19 -0500 Message-Id: <20180502011019.22812-13-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This patch contains several small cleanups: - In qcom_smem_enumerate_partitions(), change the "local_host" argument to have 16 bit unsigned type - Also in qcom_smem_enumerate_partitions(), change the type of the "host0" and "host1" local variables to be u16 - Fix error messages reporting host ids to use the right format specifier - Shorten the error messages as well, to fit on one line - Add a compile-time check to ensure the local host value passed to qcom_smem_enumerate_partitions() is in range Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 7383a0e1b468..0d7f369c3f7a 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -819,14 +819,14 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return 0; } -static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, - unsigned int local_host) +static int +qcom_smem_enumerate_partitions(struct qcom_smem *smem, u16 local_host) { struct smem_partition_header *header; struct smem_ptable_entry *entry; struct smem_ptable *ptable; unsigned int remote_host; - u32 host0, host1; + u16 host0, host1; int i; ptable = qcom_smem_get_ptable(smem); @@ -850,16 +850,12 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, continue; if (remote_host >= SMEM_HOST_COUNT) { - dev_err(smem->dev, - "Invalid remote host %d\n", - remote_host); + dev_err(smem->dev, "bad host %hu\n", remote_host); return -EINVAL; } if (smem->partitions[remote_host]) { - dev_err(smem->dev, - "Already found a partition for host %d\n", - remote_host); + dev_err(smem->dev, "duplicate host %hu\n", remote_host); return -EINVAL; } @@ -956,6 +952,7 @@ static int qcom_smem_probe(struct platform_device *pdev) return -EINVAL; } + BUILD_BUG_ON(SMEM_HOST_APPS >= SMEM_HOST_COUNT); ret = qcom_smem_enumerate_partitions(smem, SMEM_HOST_APPS); if (ret < 0 && ret != -ENOENT) return ret;