Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp50504yba; Sat, 30 Mar 2019 14:23:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7DVSROf4WZuZOdFDmz+0ON8FChpDQu1+UlXaCgg+GzDVG3YNGx48c7cGuEp4PWpjAU/vN X-Received: by 2002:a62:3244:: with SMTP id y65mr8802878pfy.255.1553981031695; Sat, 30 Mar 2019 14:23:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553981031; cv=none; d=google.com; s=arc-20160816; b=igkNAYRBSQiiOVz/+8KHrO2TCS0j7JfPhf1wkUc0w9v1JQ1KTwr3xzPU1i6iy/rtCp LUjhhX7i+6B0hIFQqlAEPFh9TIjPARq+GnVjCXZ0vPo8Qyj/USzC76jCzp8YdWAaSfnj GclqaoKPkFyGrmGpmdqv8cqxzCONzCoxMD0L+IJjIyrMtzZasaTORhziTdUp66G9mDIQ mXHjWNQ9G1CGVZEvtqw06WTNe07iI9tdxBBwO31o28OpZPz+51lxqPa1kWbVe81LzHRd L2bXg4ZCaV/0DEF11zkIOjb9rbkN3e6MLaj+kv1LnO83pMS+jXu+1Gjy95yLnyCh8zc6 /GFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=KcLNsVBXzqBFOfzhcVFDj0s8Od+cDVroxB/AqEyniTM=; b=InLDiX3EKTewzH3FSkGt2ftA88qGB9iaG+axDmEk4EXUFACg0O7ELDbN83uh4YLnSx vV4dVsiI9qDz5S7151iZeJno2a/WZ223HJzi8nNV7EFzS5SbZTNyVNu/1Dkdk8KxrQTN nKfCuJGoWere7LXJ/WST8cfeYQTf9Qi53xpurJuclgr1mWNh2CqQbLNQSFhgsZoMWd0H PJuyJJ0S3vbdvn3IV4MdXLi4TMLLYXVAcKdjrmF+SkOIWJzmzvkecYZzhVFFi2y6+BIY he+itUCzjNMHTQuSqO9SFivEws+hXVH/lSRpcUzP63GTG2oPaRfJVix39vxLN4hgKZbo hI3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 60si5598865plf.122.2019.03.30.14.23.36; Sat, 30 Mar 2019 14:23:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730969AbfC3VXD (ORCPT + 99 others); Sat, 30 Mar 2019 17:23:03 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57694 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730395AbfC3VXD (ORCPT ); Sat, 30 Mar 2019 17:23:03 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1hALRN-0003YR-7C; Sat, 30 Mar 2019 21:23:01 +0000 From: Colin King To: Mark Brown , linux-spi@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: oc-tiny: fix negative loop bound error on for loop Date: Sat, 30 Mar 2019 21:23:00 +0000 Message-Id: <20190330212300.11675-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Currently the for-loop using an unsigned int for the loop counter which is problematic when comparing it to the signed int gt->gpio_cs_count. This is an issue because if the signed int is negative (for example, the call to of_gpio_count failed) then the negative loop bound is implicitly cast to an unsigned int on the comparison to loop counter i and will yield a very large value, eventually causing an array bounds overflow on hw->gpio_cs. Fix this by simply making the loop counter i a signed int; Fixes: ca632f556697 ("spi: reorganize drivers") Signed-off-by: Colin Ian King --- drivers/spi/spi-oc-tiny.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-oc-tiny.c b/drivers/spi/spi-oc-tiny.c index 085f580be7ec..81f74b938dc9 100644 --- a/drivers/spi/spi-oc-tiny.c +++ b/drivers/spi/spi-oc-tiny.c @@ -206,7 +206,7 @@ static int tiny_spi_of_probe(struct platform_device *pdev) { struct tiny_spi *hw = platform_get_drvdata(pdev); struct device_node *np = pdev->dev.of_node; - unsigned int i; + int i; u32 val; if (!np) -- 2.20.1