From patchwork Fri Nov 15 22:33:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 179531 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp13126511ilf; Fri, 15 Nov 2019 14:34:16 -0800 (PST) X-Google-Smtp-Source: APXvYqytM0I8mqoq27IPPysFjYRtlKc24AcmwNgrzVxvqcPq/lZ4go2xSRkhHtgPfarUtWxBo/e/ X-Received: by 2002:a17:906:fad4:: with SMTP id lu20mr4515506ejb.9.1573857256793; Fri, 15 Nov 2019 14:34:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573857256; cv=none; d=google.com; s=arc-20160816; b=N4PKT7POdXYz2tyJhzqzXl85dEpMUGMv4R59r+jYIVa9fw1GAVOUr1v8p6UoUoCEc4 Vjq7LhgDiOSozPQgNcKFxXm1SX+wrlLua1ZP1pnraL8ZG6XynQeZeIim2wcPNUsjYSRS 78wkACo1Drnlim7NCp4d82cfHKt5hgrfE8evGLLuXbnBr5A/SCdqoDFyqtzhqcojW57z 2aY5t7quDq5ffvG71FjPTjk4tLpeMQinFqUXHDSLE7J6ohfkSCoOTOXLYdIrzSNpgmku tm2ZglW8Fm4aj4RN9w664ZMPzj2maxb+W14VvJIxzRti41rRzkE4z47YFKy0r/vhCZ7d Ga3A== 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; bh=4OAg+K/MSQ8LDMB5QZGzBoNYfURH+sTBMSUExg9URq0=; b=sPdj0LP5celhnRICd9bOKgdp6MJzrtdGDLbpf4fsl8IMplJk+Qki3mDGk34tSPTxRZ mM4ZmRrf7L45h8S2FXrH93QVQVbKiRs/5dBP/FCxTNTQQgJc4qBD/jBhTjbUxRB0z/+1 XOTvbhrkyorqrJXKKy68KEAeNnyLOkojhhXZsPe3v/B4iWAyAF4U5o4B2aIrMKbn38/y 92JwK6+GROwbontRznb5enEK9PMC5YAxMg4mapBvs8h6A53X8vCad9qVdKPItLdRRN/l au3pXLkqDEVx3YKDKJJVVDRiaELyASqlyvh0p6UbvA1HxNiidhfrFOOyNO2Fy3XOusYd fhkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WeIJk6lI; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (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 gq14si6458339ejb.190.2019.11.15.14.34.16; Fri, 15 Nov 2019 14:34:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WeIJk6lI; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727384AbfKOWeL (ORCPT + 15 others); Fri, 15 Nov 2019 17:34:11 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:44130 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727354AbfKOWeL (ORCPT ); Fri, 15 Nov 2019 17:34:11 -0500 Received: by mail-pg1-f196.google.com with SMTP id f19so6611849pgk.11 for ; Fri, 15 Nov 2019 14:34:09 -0800 (PST) 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=4OAg+K/MSQ8LDMB5QZGzBoNYfURH+sTBMSUExg9URq0=; b=WeIJk6lIxyCTX4RCndZxDj9cy9KCsTub6pTQq4mdaj3dFRpi65OWFqCZRA44CBtrxD wyRa0X0CmZhRMy5Zc5o6LHi1MH3tbcQL0cv6gNCqqSz1J3XAMtx2zhJ2JtE+s68O47NN zHR5m5wI7wETwcEBKNsfebJLtuRqn3mfOO7V8dd30qDbuXTHtB4c9BgZjgnwNq49NE0s sHN1LPoBsVxzNYQxP/EzcPTZ08HKWeXQ0I/7fV81CBePfnFtSebCvvcctt33pVFHmB1t 3cJcol2P9GoSGYES+I95jsL41GuvG8R4/j9nrA8bdohfjWKd0oseIzbWJkGjljUdRMSA KFlg== 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=4OAg+K/MSQ8LDMB5QZGzBoNYfURH+sTBMSUExg9URq0=; b=WDZLI/64w+aCs+DeuqwrpBLSCg//8t6NM1RF3t2EJdUtw8dUV0gD1DlptboflC4/LK dSHGKc4hC29iVTQcud3WJoBZpZSCMrsoj7fneV2ftIndgdXRsspkpd9uR3WsSMBWgkfY sDBp/+saoRYcoreWUPWp5e92o6nDXoOKxOHY4CcgwreB+1UOVXsDHUxgeZhgNBId0PQA 88BJTiKIYcyrGSLtbiyLqE9LAFZtTbwa7gtFs5+4HAKRIqcrZE4MxpcBxPu2xFE38lht tZTMIDo1qgWkwomfSIP1QmsrKo6BmkDd+AfkxQXtRxzHoWFJdX4nRbDxqFfx4cSDzToW vYSQ== X-Gm-Message-State: APjAAAXUe+bzUKPzqstQqfD09TGb2DfAn7TNxMKpKnriMnSsf2yrRkYL W0kLaQbwbvL+nW6dulybAvBUnRpRycM= X-Received: by 2002:a62:1e42:: with SMTP id e63mr7219946pfe.25.1573857248667; Fri, 15 Nov 2019 14:34:08 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id m15sm11699724pfh.19.2019.11.15.14.34.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 14:34:08 -0800 (PST) From: Mathieu Poirier To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [stable 4.19+][PATCH 13/20] mailbox: mailbox-test: fix null pointer if no mmio Date: Fri, 15 Nov 2019 15:33:49 -0700 Message-Id: <20191115223356.27675-13-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115223356.27675-1-mathieu.poirier@linaro.org> References: <20191115223356.27675-1-mathieu.poirier@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Fabien Dessenne commit 6899b4f7c99c72968e58e502f96084f74f6e5e86 upstream Fix null pointer issue if resource_size is called with no ioresource. Signed-off-by: Ludovic Barre Signed-off-by: Fabien Dessenne Signed-off-by: Jassi Brar Cc: stable # 4.19+ Signed-off-by: Mathieu Poirier --- drivers/mailbox/mailbox-test.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index 58bfafc34bc4..129b3656c453 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c @@ -363,22 +363,24 @@ static int mbox_test_probe(struct platform_device *pdev) /* It's okay for MMIO to be NULL */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - size = resource_size(res); tdev->tx_mmio = devm_ioremap_resource(&pdev->dev, res); - if (PTR_ERR(tdev->tx_mmio) == -EBUSY) + if (PTR_ERR(tdev->tx_mmio) == -EBUSY) { /* if reserved area in SRAM, try just ioremap */ + size = resource_size(res); tdev->tx_mmio = devm_ioremap(&pdev->dev, res->start, size); - else if (IS_ERR(tdev->tx_mmio)) + } else if (IS_ERR(tdev->tx_mmio)) { tdev->tx_mmio = NULL; + } /* If specified, second reg entry is Rx MMIO */ res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - size = resource_size(res); tdev->rx_mmio = devm_ioremap_resource(&pdev->dev, res); - if (PTR_ERR(tdev->rx_mmio) == -EBUSY) + if (PTR_ERR(tdev->rx_mmio) == -EBUSY) { + size = resource_size(res); tdev->rx_mmio = devm_ioremap(&pdev->dev, res->start, size); - else if (IS_ERR(tdev->rx_mmio)) + } else if (IS_ERR(tdev->rx_mmio)) { tdev->rx_mmio = tdev->tx_mmio; + } tdev->tx_channel = mbox_test_request_channel(pdev, "tx"); tdev->rx_channel = mbox_test_request_channel(pdev, "rx");