Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp343240yba; Fri, 26 Apr 2019 00:40:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzW8Aq4BwWz84JoLX+DFjSdvkn47OqcxTJLRfd6/VjB+LcrWoGMlWyh8+zz50jtGHKtMUr6 X-Received: by 2002:a17:902:e610:: with SMTP id cm16mr42307535plb.189.1556264428297; Fri, 26 Apr 2019 00:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556264428; cv=none; d=google.com; s=arc-20160816; b=pDcgj0HXI0hm67Xi/IsQCO14f81dHIFxTQMSafNMmC3OiBk06XHGOMu9MVMJHHDhGx Ma9e1p8mq9DWHSta2VBvrIro/WrvLfms7fzGxMtTx85eoJIseGMu916ZrpGZfFEJV1qe GI3OBCWnFI2I9GCApkBpmwQ8NWwWz0VIrqYjv56VBoIow96lpvBxPuJ1+xkHYaLUW8Kr vIGK7Ox9H6c3cXcDBhRXCI5CkQbHzWhrzQuMJz3LUqTI2dAqKawWUakw/PLBiPjufkYl Sk8KbNFj13RvEiKFnzR1FrPAfdh9ogi5cT3p91zoVXYhd4P7p5FU2szpKikFt0OJBhO2 VvIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/jHfLSpDYSlwKi8l7a/DEngU94lL7rYFqyxBtDimYXA=; b=yW6YTXKOOBoxeSUphEumJXeMAMVlW+fjq/O0PRB7kyScRmMLDL+ZSU/dw570fOqVA7 fBHYtzw4X1lKaSLl09TYaoM8JrlqpwbEgFG2fu9wjTyE/amYUIMD1cXpDp5WTfTB+pHB nJYpV23K1lSXPVIgdOE49zyLCeAYD+PFyEd1lGEPLxP2R5aMOilmGUI2kgifGiEqth2k B4WlKh+AZItuf9N1eG2WyuPCThyQTMTtrlk0cSFagqNdPtnsqgFpq4p+R2PKCS4Prved t9OrLYzLWgpxwHpdgY9vI+EEQQP8aiaPeSDD+KfNShsMGr7s2xcsjjUh1sM73wvg4Kv7 dRTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=lcL9mS3L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si25218716plq.133.2019.04.26.00.40.12; Fri, 26 Apr 2019 00:40:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=lcL9mS3L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726119AbfDZHjI (ORCPT + 99 others); Fri, 26 Apr 2019 03:39:08 -0400 Received: from mout.gmx.net ([212.227.17.22]:44451 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfDZHjI (ORCPT ); Fri, 26 Apr 2019 03:39:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1556264336; bh=eXVuQ4GxcSyfn1xn0uo5tTdWse+H/ZssVULo+dS1BoU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=lcL9mS3LSWTYbsmDr75NK0+owYv4AKZjIIcYOa8UGx5JB/gjP2Z9MyzVcJTieCEbT A02tQAMCB6AymIs1RLbNwZacgyUh9zDSZTzDbVJkrVVMFTxqrn7bPlFlcDtCvGt9Kg J/IhaJIhQLQSxUld3zwqIEWdrquTN9YeXN2tIf8o= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([218.18.229.179]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0LwXCt-1gjEo41SRD-018I5Y; Fri, 26 Apr 2019 09:38:56 +0200 From: Chengguang Xu To: gregkh@linuxfoundation.org Cc: dan.carpenter@oracle.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Chengguang Xu Subject: [RESEND PATCH] chardev: set variable ret to -EBUSY before checking minor range overlap Date: Fri, 26 Apr 2019 15:38:37 +0800 Message-Id: <20190426073837.23086-1-cgxu519@gmx.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:jnnTDKRqPbZvDx0A1eDgWqsaN67fPTgX38a3r2ZqdcyNAxNwdVI MZvaX+ciStiXcxrhZjAvRhm8j5wOD0RZl1Qi75+aQoY8IDD5kwGlF+mvEvZazW6Lqb8JG1K 0yG8G4I1bvxj5IqhR8BDtZfKuw5a/TnrDvUmoIYVgf5TdxXnhwRnzvbPuv8s9RRuZuHrauU 2sN2rLYhlpK0E8L1w/t2Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:oNbZKfoyKYA=:Z8ApCNUhkpE/xtVgxngKFw 89Rlw4JFrb+XiV29Cbb5uPeu8llW8gbgJhHRuU6PV+jt5zE5UDyB3HPnxIRNGaU1qy0rSepGb Symvh75azF1L5hfukz7nSMJVCsS89ZDx9irMdhnbTQ/1hHnwf0UDrJHGT1YVftZUi9rEL8hnK Pou/R++bvpRDm1wFSzdXHKqQkv2ZawB+LcIal40xXYehI4lAuGS6xindXqqugT/I1nsUwIPqj EbJoZvNzoHUSTeTOcckZSncULF4t0PPJmqIwDrajN3HCUXTcPmT9trxk4wY7QpT2ZsZ5KMs8A 5jpnpiucAEyvqzUiFOAY8HQUWPOxiG2dKKTYccVB9se4KsR0+ireh6tOoh6G64G8zFIw/MQ/3 aDr11gV/dTuvhWr00Fjb1zGWhHoV5Amu42ACokIpeuUbW/CwGTHWLskxXy3tIvDZZKMEI/2pB HLvHtmdT6sjxZoqioGx+gmyc8qzxET3BSGHrsmvCf/0At3Nq9rlWnWWdzlFuy595FHFJ55fU/ MiaX0DY6g2j9WDn4yCHwSVel0+c7gt8TgFZhJpgD/kp/ASnEeQeHxuG+tqxn6m7906iBeewXH WBfsUDstrYa1nO1XqGNih8+C+UZ6Rfhb2znZ9WmwuLhkTm6Y1uBG2J+UyB0Ct4oCP435/pf28 KKSacRwGI4AOXuyWDrQj/zPAhMlDd7LpIJ6+S/N+za18/FhMMU1M6tiry4n4e9muFlNkQxo0H Txfmh+WDRYUaLcIUrMfoZc+M6zZqMFSQhosUoRG0ycVIOEbh1k6sS/AUlp8PTdHvddzjxUMnG OHwdaUwNxmBBl6tmLp/DV5KluW5PY4rFyyVTswWOnbH3QgA49emIxgQJ6HemGiZaDBydMV92K EoK+GbjAMTe5LDDVrzrbKnSJsJDmK2g1b4S8yDfzz+8/7iY0aMYKGi2TQNuLLn Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When allocating dynamic major, the minor range overlap check in __register_chrdev_region() will not fail, so actually there is no real case to passing non negative error code to caller. However, set variable ret to -EBUSY before chekcking minor range overlap will avoid false-positive warning from code analyzing tool(like Smatch) and also make the code more easy to understand. Suggested-by: Dan Carpenter Signed-off-by: Chengguang Xu =2D-- fs/char_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/char_dev.c b/fs/char_dev.c index d18cad28c1c3..00dfe17871ac 100644 =2D-- a/fs/char_dev.c +++ b/fs/char_dev.c @@ -98,7 +98,7 @@ __register_chrdev_region(unsigned int major, unsigned in= t baseminor, int minorct, const char *name) { struct char_device_struct *cd, *curr, *prev =3D NULL; - int ret =3D -EBUSY; + int ret; int i; if (major >=3D CHRDEV_MAJOR_MAX) { @@ -129,6 +129,7 @@ __register_chrdev_region(unsigned int major, unsigned = int baseminor, major =3D ret; } + ret =3D -EBUSY; i =3D major_to_index(major); for (curr =3D chrdevs[i]; curr; prev =3D curr, curr =3D curr->next) { if (curr->major < major) =2D- 2.20.1