Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27637909rwd; Tue, 4 Jul 2023 05:57:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5oal6n2Jo7DFRlCktjt24aAW3JnPAmVJMDauIF9j6vVEnEz+BgXG84KYioXs+DbTsuq0rY X-Received: by 2002:a05:6a21:7889:b0:12c:8aa2:8b59 with SMTP id bf9-20020a056a21788900b0012c8aa28b59mr18308016pzc.28.1688475444241; Tue, 04 Jul 2023 05:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688475444; cv=none; d=google.com; s=arc-20160816; b=i4slHyo1ZZajk7vFsLYiNSU7rDnEtAOao4AQjoTIS0xwarQxqGVMrT7tx7hSwUD6de lkv8mHCTrOr8KJ2B8wBo5EpbfJShHJvHD3BNgTpSaNsHqh+67NMKeKfQrFsFCj1NO1yt 2Wk6Ctl1T/NjxhhgUUI5zuh+akAAHcbCaHiylxCcVm+EigeAZCP4mrvRH3GKgPAUEALz aififOqcJFIiF7Pc4tH2rajpOE2Kghc1Ywr2VSnXVeN5ZEdsWIQnhUb+nFw/FEedXmUl RSsTd/4yjGZmTATvNzg/mTuI0BqOHYSRmHV20f3Y1/1AfmUPlp16TqU96NP23Nro4zbp iZKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=gy4Y3Oco7V4O0qs2lvEoa7dVI3NuFWh8wF5vNDqvAfY=; fh=OAi31DR7Bv05veSJgHkvzbslJKZcBJ/GRR2ujYcQFOw=; b=y4uNuNR2ECHbdnYCTVBlpgBrtb7V1ppw47wjc1DTYRgxSYkW0pAxeIlNIoQlaGLxHs R3JiSUG5SFmuBCFZUHLDPYJHvrlQi+uXzwxL7A8J28LelpNysiyZ+vUO/9YmA4OHJUyJ dY0EgNJP5Ii3pPMRjfWv0gXOwnjVoyK3Y+F0Sy8V4TfFDvkAKge39d6VUtN9ILSaZfhD LjGBpIuXfqG+1psktkNHqy/G/LvQVPPHqNDYEJcW5b5HhGUj0fPDeqrhm6N/NFIa3tOm GBYS0sAyYRpT+xgXKqSya/QtzKtyLtbECc9g3lUxTDlStOTIb36FudQ/R5TAholBPpLE 4+DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=QgIQJRZH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a63c144000000b00530b6228f91si21542734pgi.895.2023.07.04.05.57.10; Tue, 04 Jul 2023 05:57:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=QgIQJRZH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231463AbjGDMdW (ORCPT + 99 others); Tue, 4 Jul 2023 08:33:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231962AbjGDMdO (ORCPT ); Tue, 4 Jul 2023 08:33:14 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B61D9D8 for ; Tue, 4 Jul 2023 05:33:13 -0700 (PDT) Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 77D9F3F731 for ; Tue, 4 Jul 2023 12:33:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1688473992; bh=gy4Y3Oco7V4O0qs2lvEoa7dVI3NuFWh8wF5vNDqvAfY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=QgIQJRZHNeX6RMvTIqKJyEShxtNVrzwsirfDQFjRmGeaXqph0qFA/lfKXFrsO7o6L yL7F9KC6UeSrMZESxu3aBlHi7AlBt281oLgQjO6qUm8YlMeprYZHv6fFiFXmWDWHlV GeYdg99ZP1j0GjOzKsLX0FTB3zRI0wZega1U15UlDouEqc6rOUB7XC/p9PyGO9z4fq q4uS5BH2NHtxqPtdsO5cMpjEOGYr7flijaO8GlkuZlqXdLtHUErbnnuxuQSiofeix+ 2HB/87k29RU/tqfiT3LPySM5u+PKqeoxyoT9rNIGWcPn6LKPk8A35O7MIbe7v+sOMf 4GZedonMcFLkA== Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-55afcc54d55so5704232a12.0 for ; Tue, 04 Jul 2023 05:33:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688473983; x=1691065983; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gy4Y3Oco7V4O0qs2lvEoa7dVI3NuFWh8wF5vNDqvAfY=; b=kiskt0UMHvS2k2MXItOUXVkyOd6ilowojCl6ZAIBDonXefP7doBEVVHIXGlG4VBZyM bRj5Ye6s+kgEVBI1ABc7MTeMgwkup0XiH12dXnoEQyvW1GnTUS9TppOCU0pJLFX8Fqf+ cYPSfpLU8spNTAt1i5EeX9HfU2YQhu+Np2URA1JFCFuvq9KQ/3N5G1xueNsk2GWJSNLs B1TTREkb65DIbpg5CjqB+1dYLyI5p1FkL+lTrNJFo4996kTQETdoWzO43ZIXOeuNYnLZ D0DOSO85Qh76/uKuaWyBeam+v5jwIHWutIwXXx722ugO2tIkENP+t3cUPz5mSeFkv0eE U7Fg== X-Gm-Message-State: ABy/qLa5QufvG3MKb98aPtTCTJYsK2Rs0YX8L17Dmxu0wVzjCzrIwMOp UkocPcWsRw6Prf4r5u2SZOb7jIfqCgqZKAQKnYhr3sgZ2FXdUj1AgYyDUt2XHVG7LkY09FkGBMq iK3bSAua5nbTkiqUyXkBG//JL0mUy8Has5mfFlll8HsY3N5CQWaBmuV6SrQ== X-Received: by 2002:a05:6a21:3814:b0:12e:44:a1a6 with SMTP id yi20-20020a056a21381400b0012e0044a1a6mr8431327pzb.11.1688473983386; Tue, 04 Jul 2023 05:33:03 -0700 (PDT) X-Received: by 2002:a05:6a21:3814:b0:12e:44:a1a6 with SMTP id yi20-20020a056a21381400b0012e0044a1a6mr8431303pzb.11.1688473983018; Tue, 04 Jul 2023 05:33:03 -0700 (PDT) MIME-Version: 1.0 References: <20230703162509.77828-1-koba.ko@canonical.com> In-Reply-To: From: Koba Ko Date: Tue, 4 Jul 2023 20:32:51 +0800 Message-ID: Subject: Re: [PATCH][V2] EDAC/i10nm: shift exponent is negative To: Dan Carpenter Cc: Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Elfring Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 4, 2023 at 8:02=E2=80=AFPM Dan Carpenter wrote: > > Here is a better commit message. You can just copy and paste it. > ------------------------------------------ > [PATCH v3] EDAC/i10nm: Prevent negative shifts in skx_get_dimm_info(). > > UBSAN generated the following warning during a timeout: > > UBSAN: shift-out-of-bounds in drivers/edac/skx_common.c:369:16 > shift exponent -66 is negative > > That most likely means that rows, cols, and ranks were all set to > -EINVAL. Address this in two ways. > > 1) Change the debug output in skx_get_dimm_attr() to KERN_ERR so that > users will know where exactly the error is. > 2) Add a check for errors in skx_get_dimm_info(). > > Fixes: 88a242c98740 ("EDAC, skx_common: Separate common code out from skx= _edac") > Signed-off-by: > ----------------------------------------------- have sent V3 as per Markus' comments. https://patchwork.kernel.org/project/linux-edac/patch/20230704095939.119620= -1-koba.ko@canonical.com/ Thanks > > > @@ -351,6 +351,8 @@ int skx_get_dimm_info(u32 mtr, u32 mcmtr, u32 amap,= struct dimm_info *dimm, > > ranks =3D numrank(mtr); > > rows =3D numrow(mtr); > > cols =3D imc->hbm_mc ? 6 : numcol(mtr); > > + if (ranks =3D=3D -EINVAL || rows =3D=3D -EINVAL || cols =3D=3D -E= INVAL) > > + return 0; > > Change this to: > > if (rangks < 0 || rows < 0 || cols < 0) > return 0; > > It's bad form to check for a specific error code unless there is a need. > > regards, > dan carpenter >