From patchwork Mon Dec 2 10:30:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 180601 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp5012424ile; Mon, 2 Dec 2019 02:31:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzoNcCq1KYZiALPpmhoq+swH5QOCEtuaRLwoW3mrDHI7Ik/vX54V1qpy9eFSkE6Ewap+BSp X-Received: by 2002:a5d:49c3:: with SMTP id t3mr15081447wrs.113.1575282686453; Mon, 02 Dec 2019 02:31:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575282686; cv=none; d=google.com; s=arc-20160816; b=f24Vx1xPlVdsOu4lfr/D3yrEHupyh/qt4ZojhfOTgrHs5bW8MVoycy7i5T7CInqQQr jiaW4RtIJQycYqV2CRN800vtAcmDYDVLzTSakMsd3w7YJiYJiUc3P7oFjczg+taLN65b QinTy6z2if+uSjympXXb9VUb48Qc4apSClkB4xcGICZVUhToJd59ljdv0a4lMbpZF9hX 7PsdmLH44Bw8iye4TlrmQNlLQGRI+OpR4gpUpCp45lHWTeDJnephMhDzv5nrd+WxxIrp kCSoG+00nhBC8yKxOLdMh60+yuKRwOslVH2D/WrJkyhSxGBzYB985We98gqzFnBAzlla uetg== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ZgOVOUxciAvJcn32lc/Nhslk8imEa0i2gZFv1Qv8b9A=; b=Dt+sKVkgSbB6CgZiK4Ffl9ICABS2U+rb8GR6J127iMCeOiOFboKGPNtIVhzytqZT/m 0wDq9QIjFE68eHGd1c1g19Bd68+vQGmuQj6uxDaxDjFubveWDFAxnwRW1j9KA1Qqvftw S16Ywdu7Pf2kiR5gQrdn6JOZp4rHok1lw77olK6KCsbIZEmiEeMMdn11gMxgbEH4yaAK iAEB0FWuk3xPJazM0O3Itaz06oLG9sDY2V/ezjiEYzywu0F3hdr3NRO/YDtx7bLl9MOG AUUFnsT5blniae0l4qZubQ1Jxz1RFtEgF6YUxObCNGgB3PHk6NhNzuxCR6qgFbrXifSM WCiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=drtuQ2ps; 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 e21si4015152edq.191.2019.12.02.02.31.26; Mon, 02 Dec 2019 02:31:26 -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=drtuQ2ps; 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 S1727577AbfLBKbZ (ORCPT + 15 others); Mon, 2 Dec 2019 05:31:25 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:32927 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727575AbfLBKbZ (ORCPT ); Mon, 2 Dec 2019 05:31:25 -0500 Received: by mail-wr1-f66.google.com with SMTP id b6so13900568wrq.0 for ; Mon, 02 Dec 2019 02:31:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZgOVOUxciAvJcn32lc/Nhslk8imEa0i2gZFv1Qv8b9A=; b=drtuQ2ps/fJpXBdQG48oENHMFLL4ok05/xwAlGFrSD4RGZ+v93a5nj2pzS7+BEJsV3 3G+FRQYKBDPgfMcScXvsNARNw203y1YE4ALeatNDaYL3dmBCx1neo25cePA/TDUgl3f8 kkDPYqGADhToIU5KYpHgIJCx2n4f5+WWtehmvdGpHbNRuflXe0l5pKI5aCmoY0etbi7h U0esPWBdfiyPdeXDZ+/NwfVd+OAygmXc/z8sy2bfib1nTzdBp+xBONV1KiM94Wts1OBE WJGUJKp/0bd0op7rmhNbA7D2hHCfiDMHfZj4s9J9t26hp80cu6bEAqlgPvx0x7C4XHhc gp6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZgOVOUxciAvJcn32lc/Nhslk8imEa0i2gZFv1Qv8b9A=; b=GdZHnPxzcwHX+TFq5Ww4jWtC5ENKpr+iNNF+99dstgeIO7lXIdlM2irdwzQ5toYSp0 tBSm2q4wc8zxlnojrsoTOQ2vC2Xg8P+/K4NT0Cc1LO1ZUHVVpnpfMCZ1XBE+yAx8OFE8 XQJ5JaCcyNeFCU31Rx+5N84i4ooIqH9CaVxAxenbI1C8LeMKHl6NIkheY3kklHjSDfwC s9/jUt8YT1EEMl+9Nss9M4BgVNbq37AcUS8bfEyy++EG/J0oUzATUu/MFlPkwtftdioz zWIGSFaw28I02aeVg2/b9ZrRCyZJ8mljhEi1dKQJ3zCrIv/JunBzJHv1LvDrL69cFp6t 74+w== X-Gm-Message-State: APjAAAVM0fjrf9vQ7tbH63FVK2bPxHzOO4vIFyWEj/mcMh12zToHXBhh 8gfP/Ccqsx5itydI5zEmnVCHq6tuiA8= X-Received: by 2002:adf:90e7:: with SMTP id i94mr2513688wri.47.1575282683601; Mon, 02 Dec 2019 02:31:23 -0800 (PST) Received: from localhost.localdomain ([2.27.35.155]) by smtp.gmail.com with ESMTPSA id r6sm26402860wrq.92.2019.12.02.02.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 02:31:23 -0800 (PST) From: Lee Jones To: stable@vger.kernel.org Subject: [PATCH 4.19 14/15] mtd: spi-nor: cast to u64 to avoid uint overflows Date: Mon, 2 Dec 2019 10:30:49 +0000 Message-Id: <20191202103050.2668-14-lee.jones@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191202103050.2668-1-lee.jones@linaro.org> References: <20191202103050.2668-1-lee.jones@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: "huijin.park" [ Upstream commit 84a1c2109d23df3543d96231c4fee1757299bb1a ] The "params->size" is defined as "u64". And "info->sector_size" and "info->n_sectors" are defined as unsigned int and u16. Thus, u64 data might have strange data(loss data) if the result overflows an unsigned int. This patch casts "info->sector_size" to an u64. Signed-off-by: huijin.park Reviewed-by: Geert Uytterhoeven Signed-off-by: Boris Brezillon Signed-off-by: Lee Jones --- drivers/mtd/spi-nor/spi-nor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.24.0 diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index f028277fb1ce..2e183425facd 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2459,7 +2459,7 @@ static int spi_nor_init_params(struct spi_nor *nor, memset(params, 0, sizeof(*params)); /* Set SPI NOR sizes. */ - params->size = info->sector_size * info->n_sectors; + params->size = (u64)info->sector_size * info->n_sectors; params->page_size = info->page_size; /* (Fast) Read settings. */