From patchwork Thu Nov 28 16:49:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 180452 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp373789ile; Thu, 28 Nov 2019 08:50:45 -0800 (PST) X-Google-Smtp-Source: APXvYqzmZxsystkYpfcilcR/VHOlB9ZCpXCm1KespOoPWr/nVAMKVlBo4RusPMUVWw0qo7TWykTR X-Received: by 2002:a17:906:e087:: with SMTP id gh7mr55683800ejb.278.1574959844937; Thu, 28 Nov 2019 08:50:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574959844; cv=none; d=google.com; s=arc-20160816; b=yh3/5rHaU9/dGjxT/AIj6lwCzm3TOlPJi/1QPaQ9M5dEcoR72PAx31lJ52zd6DTrBM wecN4LsUp4HElf5R/CtFSHZL3ngL6TRyE+ZqttsrkF8LfJ3k3NbUJhT1HTBzGcekQJjq oo9oaIg38Soj64NVYRr1YEuHoJh8oj3NuXvrenPoISZ4WEKc+ReNb8Qp4pJYldiuTmFB /ja7cAMp20VVZ6qgVCyYEXUbZbzK62Km05xybQDhbUaeub4F65utmJcUQJy3HUe9Xz6S n9HWBUvrOKNuP/BX2I9+ojMAYJnbs4h+MBgn4bB9KhWsmLm1yNujnJuljnb8XA6YQOrt Rk6A== 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=Dfqbr0RxajlO5BfpaJ+gj/cruGVf9oBCHGspuRMYLGM=; b=RRsbNRpQxULKAeD0wwN7VaR2e5Gj/NF4OwOnZglAyOYH/O6M3AtnE5slWGIaoUuz9v rKucJ8rXoUHNFR0QKu+0RnoHCzQEOSZWVFnE7ioZbv6Qmha+gvxDIbu3tgfs4xOJVtDS ZIyjSogYhacw2aIOz0vJLvUd9naq4IUaEMGB7aMgsZzAfLsqO6cWA0xccCk6Hwpwz1CY FecUORD27Nbvq+o9UGNeAxC5qWOYCz7wJ5R+YapkOKOvOwdmRP4vF8yNp5hVOZk37Eb2 DrTcCzOIi4+KO42ebKA/kZ0GPJ6ZLCkzWdxJe5Ddq3DTQrOcF1TNg3reyElcNzK0cD8R 9kKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O9JevNY1; 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 dc21si12388590ejb.101.2019.11.28.08.50.44; Thu, 28 Nov 2019 08:50:44 -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=O9JevNY1; 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 S1727085AbfK1QuR (ORCPT + 15 others); Thu, 28 Nov 2019 11:50:17 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45955 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727047AbfK1QuQ (ORCPT ); Thu, 28 Nov 2019 11:50:16 -0500 Received: by mail-pf1-f196.google.com with SMTP id z4so13367112pfn.12 for ; Thu, 28 Nov 2019 08:50:15 -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=Dfqbr0RxajlO5BfpaJ+gj/cruGVf9oBCHGspuRMYLGM=; b=O9JevNY1LOgHwoZQBP3JRCrkxMNX7g335LWvtIGE8TSf0gdh7CvuTTvGfjm78nXgUM +p1zMhh+nbn6ISXwf21PH0Z60BkeYpF4a6JzV8KEkI2WqyswsIDCbpxjl7X+PRhKCzIs DXpIhvG/INtLpkzRZFie2gEw9yF+o67uC62GGi7F3QILehtJeR3fMeC9qJxpd4Rb5bQn 9z5+WTrOoWg7fT07bhstV28T/EBnSeUD0loJ3jbO1F/0igGdeu3+T9Nt13ydF/Z+DFFs rkThpEXWnl23uu7cSgvOhyGVz2L72jGZfYqVGe0hqI/1KBTny0XVSPtvXsQb4D+rZIxg X5Vw== 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=Dfqbr0RxajlO5BfpaJ+gj/cruGVf9oBCHGspuRMYLGM=; b=Irc2rV5FO6EeeSCHIP/PAyt05AM95e2qPngSUsZqs3Zhby1HAAB0tjMP8l+mQffKgs +ih3rSccx70HiSCGX0nht6zsLuuQW5xQXr4ls5TFHJfv058/29CQ4qfZUnJ92b/EyWeV FL75zjKsLge3wsikL/vuryI4h2M8l1wW+qO+dGOUYL1y+n1Dqrfq7zoMy7gFEz96LR1s AqpxDLkfdanrFuhkyUta5XNBCYYzL7qZBgUPhyJ6HIX8QHHlmpy5ZyRast9wEAGV0dQY z4xie9oPWkA91KJ7Mu7oCi6UkLuj6Wbr+7KDOlkcg7wt+FRecBnXLA5t95FtNZZGuXIL vMMg== X-Gm-Message-State: APjAAAWSTySh98nyoiRC3G65sqIuGrmfsH3ymQu0K9RZZjalat/s58oI A9hGInKL7WAJbVAWAilrpuWmbGUm7Gc= X-Received: by 2002:a63:907:: with SMTP id 7mr11914734pgj.361.1574959814421; Thu, 28 Nov 2019 08:50:14 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id a15sm2450343pfh.169.2019.11.28.08.50.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 08:50:14 -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 11/17] mailbox: mailbox-test: fix null pointer if no mmio Date: Thu, 28 Nov 2019 09:49:56 -0700 Message-Id: <20191128165002.6234-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191128165002.6234-1-mathieu.poirier@linaro.org> References: <20191128165002.6234-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");