From patchwork Wed Feb 18 11:33:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 44758 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 27A9E21544 for ; Wed, 18 Feb 2015 11:34:00 +0000 (UTC) Received: by wesk11 with SMTP id k11sf396191wes.3 for ; Wed, 18 Feb 2015 03:33:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=W2lbvHMvKHsAj/G8uenFG/7AOTo9wIWc1lAPYvZZ6OA=; b=H8eaZ4AbN1ub48IvlINA40eSyrQZB105ib/JPFwwRypxRVjFib/E1Hy+0oOV7ifXmn Nqu1su2pMy+ffolLda359SPOosBzWtXxpZ2y5HDSu18uQCaIb5xZfYdznKzGLIa5mkeD PTQbnZKzuNTYHPgb3BCW6BxndS7s1BMpXmIx/Gef0DMd/JCZjh/Bly7I6reWC0r6wjnz x4yB7DHCLCK8qBeAVmH9WpmvscO0VnbfMnbdeMeAaZJx1oc9LXxOXlrNaFMeArNFBZ+5 /lgo2PRahMAXIr16z+5N9jZJaHA4umv+x4iSVB1jNVI86raScRwtTU8gqK05Ew5duxaq Zr/w== X-Gm-Message-State: ALoCoQnxo2KxiOKGTLS1TBGb/NJwcMTjwGYRIQ786AFG+7CmvSpSn+gaNK0HYlAvzDJIAaIFGewV X-Received: by 10.112.144.130 with SMTP id sm2mr4024050lbb.9.1424259239447; Wed, 18 Feb 2015 03:33:59 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.200 with SMTP id la8ls4402lac.90.gmail; Wed, 18 Feb 2015 03:33:59 -0800 (PST) X-Received: by 10.152.87.3 with SMTP id t3mr31555047laz.19.1424259239251; Wed, 18 Feb 2015 03:33:59 -0800 (PST) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id yh1si12415695lab.112.2015.02.18.03.33.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Feb 2015 03:33:59 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbiz11 with SMTP id z11so470431lbi.8 for ; Wed, 18 Feb 2015 03:33:59 -0800 (PST) X-Received: by 10.152.43.51 with SMTP id t19mr21571043lal.73.1424259239170; Wed, 18 Feb 2015 03:33:59 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2792293lbj; Wed, 18 Feb 2015 03:33:58 -0800 (PST) X-Received: by 10.70.21.195 with SMTP id x3mr34112880pde.73.1424259237320; Wed, 18 Feb 2015 03:33:57 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bw1si673890pab.201.2015.02.18.03.33.56; Wed, 18 Feb 2015 03:33:57 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752519AbbBRLdk (ORCPT + 28 others); Wed, 18 Feb 2015 06:33:40 -0500 Received: from mail-lb0-f178.google.com ([209.85.217.178]:41802 "EHLO mail-lb0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751595AbbBRLdh (ORCPT ); Wed, 18 Feb 2015 06:33:37 -0500 Received: by lbiz11 with SMTP id z11so468475lbi.8 for ; Wed, 18 Feb 2015 03:33:35 -0800 (PST) X-Received: by 10.152.28.73 with SMTP id z9mr19980543lag.28.1424259215265; Wed, 18 Feb 2015 03:33:35 -0800 (PST) Received: from khorivan.itg.ti.com (32-55-93-178.pool.ukrtel.net. [178.93.55.32]) by mx.google.com with ESMTPSA id w16sm4149125lbk.20.2015.02.18.03.33.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Feb 2015 03:33:34 -0800 (PST) From: Ivan Khoronzhuk To: matt.fleming@intel.com, ard.biesheuvel@linaro.org Cc: leif.lindholm@linaro.org, linux-kernel@vger.kernel.org, Ivan Khoronzhuk Subject: [Patch v2 1/3] firmware: dmi_scan: fix dmi_len type Date: Wed, 18 Feb 2015 13:33:19 +0200 Message-Id: <1424259201-24886-2-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424259201-24886-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1424259201-24886-1-git-send-email-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ivan.khoronzhuk@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , According to SMBIOSv3 specification the length of DMI table can be up to 32bits wide. So use appropriate type to avoid overflow. It's obvious that dmi_num theoretically can be more than u16 also, so it's can be changed to u32 or at least it's better to use int instead of u16, but on that moment I cannot imagine dmi structure count more than 65535 and it can require changing type of vars that work with it. So I didn't correct it. Acked-by: Ard Biesheuvel Signed-off-by: Ivan Khoronzhuk --- drivers/firmware/dmi_scan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 66fda58..07d2960 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -78,7 +78,7 @@ static const char * __init dmi_string(const struct dmi_header *dm, u8 s) * We have to be cautious here. We have seen BIOSes with DMI pointers * pointing to completely the wrong place for example */ -static void dmi_table(u8 *buf, int len, int num, +static void dmi_table(u8 *buf, u32 len, int num, void (*decode)(const struct dmi_header *, void *), void *private_data) { @@ -117,7 +117,7 @@ static void dmi_table(u8 *buf, int len, int num, static u8 smbios_header[32]; static int smbios_header_size; static phys_addr_t dmi_base; -static u16 dmi_len; +static u32 dmi_len; static u16 dmi_num; static int __init dmi_walk_early(void (*decode)(const struct dmi_header *,