Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp501936pxk; Thu, 17 Sep 2020 08:34:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNzCYmfZJwdHqLU4B4AgoedUc8tfHtjivvw6Fm6d/AYY4H4txA0TonCwtgauWZAE31+eBY X-Received: by 2002:a17:906:f1d5:: with SMTP id gx21mr29606616ejb.165.1600356886379; Thu, 17 Sep 2020 08:34:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600356886; cv=none; d=google.com; s=arc-20160816; b=AQutXNe18xPZEI94hgovsOwmrjcpZeYoftfIjAHpEha3dU5xc2fQaIlRyyt1L4HXr/ 8o3kiMe7hUkYEIzJjLHbCfgY+ZcDyPxE1GsL4G+wT02cJf0hQaQYFNt3AwGeWZMNPjl0 2RfiNjJ3SJqDqID9ouuNIbGJi9YbHQbwMCN4xpLmZAQxy6tgOQD3DXb1+FwcRa76WFGz PpzGOfwUu0otwbvrz08oKxRyEeU++1sJzcYKmbpp2ssh7K4LlPruidsVoBKTZ/Sob3B1 jTPjtlHIbhp9bJGmazl8jLw3ELAXIHgVZ27PIssKARJYKq3bppXcPEQWPOZCeSf7cDMN lWjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=DrwIZbcXlWFVHCR2HWKNIQaDitjLI4BtDBGLUzV8mCw=; b=aX7hMOqibAePR5WigvWtuwYfsrY8BvfakAHpWWmIJHJwkExPrLi4Qspwlpqhu3mgVi tMGCrEYdKa0jrxgWt0Jg8ONYu+nycPJQzxPef34dN2DMINTbaAzI93XcMH8ZRo6hCmxG KOBK34wfLH0i+sphT5f5pRwDDwXIwDimnlT4Q0UcMxJuePvrJzXk4PwRmx4JGTM/w1cw WPukUakqiClP5Y17SssloUTlJPt7F6GlPXTyitXdnJz/Yc2x+T5AfOaevdicxLnVuiFE 81UP1nxVQu4bN5wIpPlzab5IeaVzyRBFsDOGRh1eRmkb4zREsSh8rWVISRvbcMWz1Fz6 kNYQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u13si175903ejt.286.2020.09.17.08.34.21; Thu, 17 Sep 2020 08:34:46 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728254AbgIQPcd (ORCPT + 99 others); Thu, 17 Sep 2020 11:32:33 -0400 Received: from smtprelay0233.hostedemail.com ([216.40.44.233]:56994 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728125AbgIQPb2 (ORCPT ); Thu, 17 Sep 2020 11:31:28 -0400 Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave01.hostedemail.com (Postfix) with ESMTP id CAB7D1813B78B; Thu, 17 Sep 2020 15:30:01 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id F3AFD182CED28; Thu, 17 Sep 2020 15:28:14 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3167:3352:3622:3867:3868:3873:3874:4321:5007:8603:10004:10400:10848:11026:11232:11658:11914:12043:12297:12438:12740:12760:12895:13019:13069:13255:13311:13357:13439:14659:14721:21080:21627:30025:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: shock03_2c15c0f27123 X-Filterd-Recvd-Size: 1891 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf07.hostedemail.com (Postfix) with ESMTPA; Thu, 17 Sep 2020 15:28:13 +0000 (UTC) Message-ID: <707865b7ccc9168177940cd4f63cf7cb9ead2d63.camel@perches.com> Subject: Re: [PATCH v2] EDAC/mc_sysfs: Add missing newlines when printing {max,dimm}_location From: Joe Perches To: Xiongfeng Wang , Borislav Petkov Cc: mchehab@kernel.org, tony.luck@intel.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 17 Sep 2020 08:28:12 -0700 In-Reply-To: <591e613e-0b53-028f-08fd-3d62a35b8c4f@huawei.com> References: <1600051734-8993-1-git-send-email-wangxiongfeng2@huawei.com> <20200916170052.GO2643@zn.tnic> <591e613e-0b53-028f-08fd-3d62a35b8c4f@huawei.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.4-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-09-17 at 19:38 +0800, Xiongfeng Wang wrote: > On 2020/9/17 1:00, Borislav Petkov wrote: > > On Mon, Sep 14, 2020 at 10:48:54AM +0800, Xiongfeng Wang wrote: > > > @@ -813,15 +817,21 @@ static ssize_t mci_max_location_show(struct device *dev, > > > char *data) > > > { > > > struct mem_ctl_info *mci = to_mci(dev); > > > - int i; > > > + int i, n; > > > char *p = data; > > > + unsigned int len = PAGE_SIZE; > > > > > > for (i = 0; i < mci->n_layers; i++) { > > > - p += sprintf(p, "%s %d ", > > > + n = snprintf(p, len, "%s %d ", > > > edac_layer_name[mci->layers[i].type], > > > mci->layers[i].size - 1); > > > + p += n; > > > + len -= n; > > > > What happens if that subtraction causes len to wrap around and become a > > huge positive unsigned integer? If you're really concerned about wrapping, use scnprintf.