Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1944859pxb; Wed, 10 Feb 2021 23:26:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRo1EHJQrcAaBexso6etCL9NK9D+frXIKVo6qZ0icnLvtlQh+x9R4yCFYYaV7sGwnoWhZs X-Received: by 2002:a17:906:a2d2:: with SMTP id by18mr6737164ejb.262.1613028361448; Wed, 10 Feb 2021 23:26:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613028361; cv=none; d=google.com; s=arc-20160816; b=qldlUs4mqcp1/v4Qtuh/+jV2D75Rffq2ENz57Zhb6S6C/Wv5h/0SvBoHEgta/Qbpef nUGLaQ0S524gVvLNHLWKGovNnUD8R5QKuo9UPTFk4frTwCc3ute34AdwxuWhCgmvb1mn HSQj35hxtaoAsc7XYP5RJ3Myt2Etb5LM7X5AJ61Ekv/lptIiQH7AJl62AUGHj2ibz24A u4jDLWiPRPjeHPXoZvucQtl2J6qtagpFTnJggZBgxgGGFPHorVsIhgb2H0Zi3TMQXkzJ qEinUdcVbwrDIN8Z9ZnA8qCX4nLE7+kBzXxmGms0xUlgT18gaoxBL0P4LIgUDFWqUqFP r9iA== 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=k+oNx4FopK1mWbG8NXk3jDGWjeQQT1gikjqjkMNYvQQ=; b=rsrAY5m9NYxPvP1NUXDrwdk7TsAGBsmkG/Garw4PDASoSW7A48jai/iBlPUc9c0H0m OYLzB2m6x8wRSIcDEjPGJTLe07i7iDJ3uUc67Xz/Dz2Xsfuv7F8VImi/3iPjXh118OED UnnvKzbEc1ZupNJsIYDkws3FrHBShUqTiKGgr2uZ1BCndlM1FpSQee4jzBuSEYEl0VEU A/mHKTHAzQhc8K/AGHXLhJZomHcNlDyjTHd6oRtNscu10EDF3Bj8VZ9YN1y9Y74u2uCy LDHQkU4Nm4OpZUXFFD7z7eS+pjqyyiZl9L01KGNbelYDbqLp1kG9UPd7XQthAzjreuiO cn1Q== 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 w13si3215610edd.262.2021.02.10.23.25.35; Wed, 10 Feb 2021 23:26:01 -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; 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 S229585AbhBKHZJ (ORCPT + 99 others); Thu, 11 Feb 2021 02:25:09 -0500 Received: from smtprelay0232.hostedemail.com ([216.40.44.232]:58398 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229533AbhBKHZI (ORCPT ); Thu, 11 Feb 2021 02:25:08 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id B098A180A68C3; Thu, 11 Feb 2021 07:24:26 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:960:966:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3872:4321:4385:5007:7652:7903:10004:10226:10400:10848:11026:11232:11473:11658:11914:12050:12297:12663:12740:12760:12895:13069:13311:13357:13439:14659:14721:21080:21451:21611:21627:21990:30012:30054:30070:30079: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: cart80_3f0d51b27616 X-Filterd-Recvd-Size: 2439 Received: from [192.168.1.159] (unknown [47.151.137.21]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Thu, 11 Feb 2021 07:24:24 +0000 (UTC) Message-ID: <7b4105ca8671a2962910deb5418a934bf07d1458.camel@perches.com> Subject: Re: [PATCH v4 2/2] pinctrl: pinmux: Add pinmux-select debugfs file From: Joe Perches To: Dan Carpenter , Drew Fustini Cc: Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Tony Lindgren , Andy Shevchenko , Alexandre Belloni , Geert Uytterhoeven , Pantelis Antoniou , Jason Kridner , Robert Nelson Date: Wed, 10 Feb 2021 23:24:23 -0800 In-Reply-To: <20210211071153.GJ20820@kadam> References: <20210210222851.232374-1-drew@beagleboard.org> <20210210222851.232374-3-drew@beagleboard.org> <20210211071153.GJ20820@kadam> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2021-02-11 at 10:11 +0300, Dan Carpenter wrote: > On Wed, Feb 10, 2021 at 02:28:54PM -0800, Drew Fustini wrote: > > + ret = strncpy_from_user(buf, user_buf, PINMUX_MAX_NAME * 2); > > + if (ret < 0) { > > + dev_err(pctldev->dev, "failed to copy buffer from userspace"); > > + goto free_gname; > > + } > > + buf[len-1] = '\0'; > > + > > + ret = sscanf(buf, "%s %s", fname, gname); > > + if (ret != 2) { > > + dev_err(pctldev->dev, "expected format: "); > > + goto free_gname; > > We need a "ret = -EINVAL;" before the goto. sscanf doesn't return error > codes. Normally we would write it like so: > > if (sscanf(buf, "%s %s", fname, gname) != 2) { > dev_err(pctldev->dev, "expected format: "); > ret = -EINVAL; > goto free_gname; > } > > I'm going to write a Smatch check for this today. It's a pretty frequently used style: $ git grep -P '\w+\s*=\s+sscanf\b' | wc -l 327 A grep with -A5 seems to show most use some additional error assignment when checking the return value. $ git grep -P -A5 '\w+\s*=\s+sscanf\b' | grep -P '(?:return|=)\s*\-E' | wc -l 174