From patchwork Mon Dec 2 10:03:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 180575 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp4982623ile; Mon, 2 Dec 2019 02:04:09 -0800 (PST) X-Google-Smtp-Source: APXvYqwQi4JcTY/fk5KbOk9AKCaWeJuMPYUwbFaLP3qxAaehH07YyfmPXDc89vE4LwNf1HM8os6A X-Received: by 2002:a17:906:ecf9:: with SMTP id qt25mr7452295ejb.331.1575281049066; Mon, 02 Dec 2019 02:04:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575281049; cv=none; d=google.com; s=arc-20160816; b=VPJOKzFkNf98/YK7a6pBgEFcWpZM1yw13UT7ktoz4gJ6vpDRvEqlK1Z2iQIvWYfrcu /UpCWijdLVw2fsAoQXV+pa0wWX3n7jl2iszc5rQEkP+BWebtQ0YzJL2ciTkxIaaRuz/G 5h1gmDax4TcdeQmFSME5m5S1xF3cB7GoPlrJutX0NBFzCd+T4zY45ytBmzRWlu0qeEJH fyLxKJMSQpvPLJV+XLYC9B5+ZIAHUlwN2G8FGRzmew9IDxoSE4kWjnkDnTy8mifOv5g+ TY1aBT5Il0q0t9V4HUVUmjQmFJru/itAXgkdAmQrzxcXqmD60SbX26kzRlU+uN0Z1EN1 xLBg== 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=PQ3vTayhg9dI4DRY5KzmFS+ZI1OUJq8YM60IUamu6Zk=; b=rl7aFdjDVmY+xPfQNeoga0NwrEAb3lXLwqQ7ZK6a94QFvUXtcb1Sr8G+yKZ0uZ+JYk fqfU6MYcSK3fbupahQuC3hKK6ppAYFtr/Okx58uIXGGYQER8DasX/9CTgBSYHqyGXAdl 9jI5OffNm6UAe3G/XdrqQqd88f15idSLF4Mggqu8HAUsWlqa4SeoEhFNjh7S4Gfs2Ebp s+7kNWey4Y0vBFfQpYPtXU2u3blEwAjvEeQ3dhNbSdXr8pUJGSl2pQodPTB/GIvj+gAC xim7WlG10DGxlDG7nB6Z4w66i8pMgT9cKYP6Q86boxqaqSrjuWYZTaCJPU2ha2WQKPg3 ezKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CkSMeFFb; 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 p21si21018960ejz.196.2019.12.02.02.04.08; Mon, 02 Dec 2019 02:04:09 -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=CkSMeFFb; 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 S1727312AbfLBKEG (ORCPT + 15 others); Mon, 2 Dec 2019 05:04:06 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37058 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727326AbfLBKEG (ORCPT ); Mon, 2 Dec 2019 05:04:06 -0500 Received: by mail-wr1-f68.google.com with SMTP id w15so12448742wru.4 for ; Mon, 02 Dec 2019 02:04:05 -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=PQ3vTayhg9dI4DRY5KzmFS+ZI1OUJq8YM60IUamu6Zk=; b=CkSMeFFbfFnffmFzGIlUI+GKcfJPkVXNI2+6h6m9loRymOdPG6H6G2SO7iq7yV9o33 Wio9M8K3VLKAJBEMeKj1VUyjzwq3iosLDBcGO42JOVu0K+xrPyXcFhPOGOmh+/CBQEhB FPISibRfHjAI8dK5d7L5c9rYLY4gvqc/l1BF4fq927Nk+Y/GiokyGco8Zp4qa5NnwJvY OrwSXYrqIADN3QbL79z9U9aesYSnLGN2Um7xS/0Tavy6fom4vtth03rZvTWv71AxaQHx sFukBRwMmJoRcQvNWfeBclM1TU/05QLNXR6jTm74HTDb1uwVVP+qX7OgWV51LecBUNuO Jwow== 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=PQ3vTayhg9dI4DRY5KzmFS+ZI1OUJq8YM60IUamu6Zk=; b=HvYb95B+hRV61sd1biRaN/v7iwt4TnBBLl1fHB1eayzRsDnAO91D3f2Rq0BhsS3DL6 soBS9dgyFQrhhVI/R5P6EFwFAG0MTNatInFGwjdYh7X0q14WqqoA2Hi7k3wyu51z65hv 25ZpDBVP/2d1eFmXhAdNS5AjLMMPXb7a9iqNYl6UlYDLcLvjEdgElGA11e1IMxGIc6hn 9eKGW3/X+k0091ZWEtq65FbkHT5T1Opdv3sC4EN7D/7fZqU6HWPNAzNhUpEBPsa/8SfN 65b2iirDqgf+iHw1DtxvHaNzbvLRnMPFoDXN7JQUQTgZIVD/xQ/dpZKzbUKK+xjuXv4O DbDw== X-Gm-Message-State: APjAAAXJtnDSLfL4F+EjXXrkkNTb/DYWSp97dvtGcJldHlxi8EA8mcjC B3bv9lBiMOH+/jlrgUkWJvLFq0mzSZ0= X-Received: by 2002:adf:9c81:: with SMTP id d1mr66931386wre.144.1575281044118; Mon, 02 Dec 2019 02:04:04 -0800 (PST) Received: from localhost.localdomain ([2.27.35.155]) by smtp.gmail.com with ESMTPSA id h8sm22975665wrx.63.2019.12.02.02.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 02:04:03 -0800 (PST) From: Lee Jones To: stable@vger.kernel.org Subject: [PATCH 4.14 13/14] mtd: spi-nor: cast to u64 to avoid uint overflows Date: Mon, 2 Dec 2019 10:03:11 +0000 Message-Id: <20191202100312.1397-13-lee.jones@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191202100312.1397-1-lee.jones@linaro.org> References: <20191202100312.1397-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 6c013341ef09..d550148177a0 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2382,7 +2382,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. */