Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5152643pxb; Mon, 15 Feb 2021 10:54:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkaXQNwDfMhvFfNmiSxy8J89k8BFXU3ct8MVDWw/7EGTQppR7h4hOgnE7O6DZDY/gSeEWj X-Received: by 2002:a05:6402:1155:: with SMTP id g21mr16958468edw.279.1613415258111; Mon, 15 Feb 2021 10:54:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613415258; cv=none; d=google.com; s=arc-20160816; b=fO9wjyYAUNEPsd9TU2QRNt/ZD5Cgv9MdbVfAR86D9XIUpBkfsMusz9HDoQZPIZ2G/1 e6N/dfxNalOALATwnM+KWJZOCfM4SW7eSrnR88Fpv5k6FiUMDIPwbs1mmzpIHEZgL96H INyt6FzzmBBk1lXpD/q3NKE0PJG13NeLPB1ZGOk7zUpJQaCrpMJDJkW+FstDikYQvZsE fYDi/7cqq89mj+PRBTBQq4b50m0F8rE9N3LY/ipreHfXBnpQgEdrO3szO/Bh5yXQNwuD XoIHj6ntayjHdfcVz5D3k8GMmBiavIzqopa/EIHKgqj4UxvWtss5aSY0YPZ5o9n3naIb rn0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FXWa925AIO3LIH/jmOKxAvLuXR6xeq8EAPoo9G/LVPs=; b=KGScxDH/kvUFwPFp0EvBt/kovMOsqG44wZSDMIfVfnu6I5uwRsmbLfxfwTkJqc6wnr zROf6WQr54u1A1I2cQ71lKJUtSGEVy/h2qaszc3E0jQHOfkCwPd2t9UbltfdN3J/fxHp 7QAwHvMuNBsZhC99BWSM6S2k7lp63qcqhzZznerQy4PFE5DY1yBfFgL8aB5Sf6r7ijd1 6qxB8322tuBpRV9rIutG+9BFYRMi5vTOP8n8Vi2/Y0bnQB+nkEHryYAYw3k/fQsMcCaD FxhQ4W2oDccKJrvJSRZnKsrNbEtipDWVBrQPXVY4KwKZVoKos4V6IpDmGK4HMbXtQkxK Vt6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mwJuO+uI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bw26si12520756ejb.644.2021.02.15.10.53.55; Mon, 15 Feb 2021 10:54:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mwJuO+uI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230462AbhBOSw1 (ORCPT + 99 others); Mon, 15 Feb 2021 13:52:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbhBOSwJ (ORCPT ); Mon, 15 Feb 2021 13:52:09 -0500 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7237EC061788 for ; Mon, 15 Feb 2021 10:51:29 -0800 (PST) Received: by mail-oi1-x22a.google.com with SMTP id u66so8707278oig.9 for ; Mon, 15 Feb 2021 10:51:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FXWa925AIO3LIH/jmOKxAvLuXR6xeq8EAPoo9G/LVPs=; b=mwJuO+uIPO1JIGp9GCaya7q/7P2IO6XqwIU5FmY3duvnqxZe2Ayg2KCoQq2PupLGY7 ET5ehCApl/uoprsXlCr/EdyCQqMkQGiQu2sVM3H9at/K2AwzZXuBisDJvjx/GPgn9SD2 kpoe689fJBRTXXED7iD7X6yNb5YlEA0NO37Z2tW4tLXZ6Fq2h/Sig+NPemq/fmdGO/Nb 2SUXtkZFFQyVHHgzVClcOobK3CGveDpq9cD+AM1k06eEbhMS0DVzTEKQIAlaHjgQoikJ /Xiw5e5kNE01cmS8WbFFNFS/gGfzQ0haxRZQX9Uvc00ND8eHXnK41wbXD67rC8HGg2Bq /Rhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FXWa925AIO3LIH/jmOKxAvLuXR6xeq8EAPoo9G/LVPs=; b=S6bE/Ad39d5mH1/DOX+6MlG9hk4DYgob9OV67LeNuF5Q1VR5dthl+mq17dVr3UqJTL kTHAJtJ5nXZklYxzNdT5jTKqvVpZldGeZnQ0LdL5PbLKR95fRYjPHdAB3L7DTmmjlJN0 oZVpokey1eQi1khvGV7PgT6TgzfXchgQKjrHC65TmKSiDB6+pSZH/tG2KB4+26fDS9fX 2VfBT2rFaGtE5yg6Q5NuaU8YrCytpFZ5fBmjWL4jpDHAGp3c++syFomFsQvFinVolR3I ubDAP15AL9zWwq3jlKjXW4tOSlndiTIKwwqx9wCtEYONpsAQjHUH+EzTtVLWdc89iEin KtMQ== X-Gm-Message-State: AOAM5328l8PevS2yGnlWpL4xjzH5IW4dRFKtzAnOIoXjHwVOpGb57Wwd UqzY+3F3wowfKSLcZvnft4laYDfl15i1K8MaAY8= X-Received: by 2002:aca:c786:: with SMTP id x128mr212794oif.120.1613415088943; Mon, 15 Feb 2021 10:51:28 -0800 (PST) MIME-Version: 1.0 References: <20210210212330.GA880153@embeddedor> In-Reply-To: <20210210212330.GA880153@embeddedor> From: Alex Deucher Date: Mon, 15 Feb 2021 13:51:17 -0500 Message-ID: Subject: Re: [PATCH][next] drm/amd/display: Fix potential integer overflow To: "Gustavo A. R. Silva" Cc: Harry Wentland , Leo Li , Alex Deucher , =?UTF-8?Q?Christian_K=C3=B6nig?= , David Airlie , Daniel Vetter , Huang Rui , Anson Jacob , Lang Yu , Nicholas Kazlauskas , Maling list - DRI developers , amd-gfx list , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 10, 2021 at 4:23 PM Gustavo A. R. Silva wrote: > > Fix potential integer overflow by casting actual_calculated_clock_100hz > to u64, in order to give the compiler complete information about the > proper arithmetic to use. > > Notice that such variable is used in a context that expects > an expression of type u64 (64 bits, unsigned) and the following > expression is currently being evaluated using 32-bit arithmetic: > > actual_calculated_clock_100hz * post_divider > > Fixes: 7a03fdf628af ("drm/amd/display: fix 64bit division issue on 32bit OS") > Addresses-Coverity-ID: 1501691 ("Unintentional integer overflow") > Signed-off-by: Gustavo A. R. Silva Applied. Thanks! Alex > --- > drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c > index bc942725b9d8..dec58b3c42e4 100644 > --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c > +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c > @@ -240,7 +240,7 @@ static bool calc_fb_divider_checking_tolerance( > pll_settings->calculated_pix_clk_100hz = > actual_calculated_clock_100hz; > pll_settings->vco_freq = > - div_u64(actual_calculated_clock_100hz * post_divider, 10); > + div_u64((u64)actual_calculated_clock_100hz * post_divider, 10); > return true; > } > return false; > -- > 2.27.0 > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx