From patchwork Fri Jul 14 12:07:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 107794 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp892720obm; Fri, 14 Jul 2017 05:13:29 -0700 (PDT) X-Received: by 10.98.137.202 with SMTP id n71mr4873753pfk.207.1500034409710; Fri, 14 Jul 2017 05:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500034409; cv=none; d=google.com; s=arc-20160816; b=T8MHRxivmP6lrO93z0N74rZLb5ILJL/wlsoTwyZO9gOoYOQ5WjyDwXhb70Zagayojq q1kj/Q/11QkCdh5vRLs0sEu0Zg9ulDtaR13HB2EBFQ+r3UR0fRmnrnpgbzDbB5HfrFeo IOTv5M2Bv+bDemqSU67HfA55DITSWH2qBh5Iq5GDstdj+mRik7H/6nqsuMztS7R5KS+9 EvS8AHppRwUVdS6t6loozOf+ons25GgNWz5XB8sizyG5C7PlAJm2QCuTOqxErpTJ6XWR FacODGoogPb1eMcesA+ot8iAwIoyNmCRD5OES8GCnLSgvYWtGAjqvsm435A9V59CYnjE WOWw== 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:arc-authentication-results; bh=YQbYuccEgF9+FLz9dd+1GQw0ku+q1Tk8nbFTCxj6Zgw=; b=V3NNT/esonRwtHJcW/6R64ufEVe/+4JFpXEiASnpErwY7am4AEM2wzdmvTXcYmhEDx yC9K1kknOX51Za0vfiq58TiEZ/1io9DZJ4w8wbVHqmEu9frVa0iQfq5/jdy2h+/CU6iA 2G4xxerCnCzB/FI+AxyrICgFZ2EdUsQHgEAaBSsq7F306MI0JDcBuUW65HIxU5LeMYZF pEHO59IWQR3q8a5GOc4g67Qxl1e2y5LnMpMFZj3YXdJwXGMJVkXhQCGuI/tDeW0NcOr5 WQtJT7iAlyY3LVd83VAmsVjDGorOskeRMgFPjzq6EHjEIXzmG5zSE+r8FlmHXLBHBjHt Zuaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y4si6245147pgc.233.2017.07.14.05.13.29; Fri, 14 Jul 2017 05:13:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754214AbdGNMNO (ORCPT + 8 others); Fri, 14 Jul 2017 08:13:14 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:64213 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932170AbdGNMNL (ORCPT ); Fri, 14 Jul 2017 08:13:11 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0MDxlf-1dRGlY1LOZ-00HPfU; Fri, 14 Jul 2017 14:11:47 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Mika Westerberg , Andy Shevchenko , Linus Walleij Cc: Greg Kroah-Hartman , Linus Torvalds , Guenter Roeck , akpm@linux-foundation.org, netdev@vger.kernel.org, "David S . Miller" , "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org, x86@kernel.org, Arnd Bergmann , Hans de Goede , "Rafael J. Wysocki" , Wei Yongjun , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 18/22] gpio: acpi: fix string overflow for large pin numbers Date: Fri, 14 Jul 2017 14:07:10 +0200 Message-Id: <20170714120720.906842-19-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170714120720.906842-1-arnd@arndb.de> References: <20170714120720.906842-1-arnd@arndb.de> X-Provags-ID: V03:K0:svydAwJjRiW1PP1kUc+lEX50KZYH/juMswWzA+MAZdFAykVUH3D CRMwb+92cSH994sKWp8fPOFGXLDyCwY5dNoouxNOyfcfEfstjjR/yL4P2GTSiMMR+T1iG5I 1HG7AnhZymy1ME9l48G07lzbRX5H5NsZGj2fNabgY9y/cCN8abzaKrqVJrd/9oHAUpeNnDL NMqLfhCfIyMElNsX1oEug== X-UI-Out-Filterresults: notjunk:1; V01:K0:piGDOK6iX9s=:bXLMzTZTLMcdGFXG6cVW5t lVDm/ZvJAlzudfewiIaWsJBnesLyqjRS9IdzzA+u2ebkejNxm3hLor9r31Qt0Q6AfkbR+ijLh SWjwxHieg+FCRzCGGWdt8e/VQ5k3A7UNx9EzyQyraorIINbcmQKD0D73YDzWiYn6BBEd6f8qK GbYGHZwJiuMY4sYoPyMCDfbomkD1PQ6ArDzDRWzn6m7YbVJWddO36oFNR5dPbyEZHlAXvyVH5 CPsWC5PhLlHm4NSa9Nz6FWfQG+LehMQhc/rn/EcCbUqv9lny3UdQqVmNSATEtx0tyqAVqAuDZ mtZEjno+c6z3J+w6SpUp0arUu5SsGJxlxqE0DHdyg0J6RzGDL1M/uIkT9rn+XBuNuJTOmsq+E +e3zitIwDJdWLzEDXaUD4IEYF2aEcGrOjiVA1/WCgjf9Fgls6mIy2DsWYtMWvXhnp0mmJVV/8 Svf/8Cf+NxBU95R0NIl+ptwcLfJSQQv8o4yBo8/NJTZgVMKsQUy1gsAu/+3eMQiJaHIwzF7go /KwzuvY/aYNSP9+JzbgclGz8852buDxCDsNVGScn1UitBqRGv6LiGQ/zRRt2lRVugHhmZ4wEK cItDM25SIr5NVRoeaYBO/3+nzrXYfbFe1QL6FmWvipZvBNatFNZN9lq3lEZqYXV0fWAiungnn WkHpgGzVHht4i+fHF4fCYEZ0KuMLUApnVZpJYF9/rtRiVgz3jT8rRH4J5tgpgkC/qd4RSa09V P7Goi4aRhG1bb6401TlXsy1TEaE63hDaPRrisg== Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org gcc-7 notices that the pin_table is an array of 16-bit numbers, but we assume it can be printed as a two-character hexadecimal string: drivers/gpio/gpiolib-acpi.c: In function 'acpi_gpiochip_request_interrupt': drivers/gpio/gpiolib-acpi.c:206:24: warning: '%02X' directive writing between 2 and 4 bytes into a region of size 3 [-Wformat-overflow=] sprintf(ev_name, "_%c%02X", ^~~~ drivers/gpio/gpiolib-acpi.c:206:20: note: directive argument in the range [0, 65535] sprintf(ev_name, "_%c%02X", ^~~~~~~~~ drivers/gpio/gpiolib-acpi.c:206:3: note: 'sprintf' output between 5 and 7 bytes into a destination of size 5 sprintf(ev_name, "_%c%02X", ^~~~~~~~~~~~~~~~~~~~~~~~~~~ agpio->triggering == ACPI_EDGE_SENSITIVE ? 'E' : 'L', ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pin); ~~~~ This can't be right, so this changes it to truncate the number to an 8-bit pin number. Fixes: 0d1c28a449c6 ("gpiolib-acpi: Add ACPI5 event model support to gpio.") Signed-off-by: Arnd Bergmann --- drivers/gpio/gpiolib-acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" 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/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index c9b42dd12dfa..c3faea724af8 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -205,7 +205,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, char ev_name[5]; sprintf(ev_name, "_%c%02X", agpio->triggering == ACPI_EDGE_SENSITIVE ? 'E' : 'L', - pin); + (u8)pin); if (ACPI_SUCCESS(acpi_get_handle(handle, ev_name, &evt_handle))) handler = acpi_gpio_irq_handler; }