Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp331012pxj; Tue, 1 Jun 2021 23:44:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzm9Fn8xmXhnreTkgUgS0Dz7lEWdoXdNERiELyLBWBKGKybhD4rWazpLSWnENRkhL35PKzd X-Received: by 2002:a05:6830:12c6:: with SMTP id a6mr25071264otq.43.1622616194478; Tue, 01 Jun 2021 23:43:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622616194; cv=none; d=google.com; s=arc-20160816; b=XmK69y/SDxkb8XKlwonGpQ89hjH4sLiBhWnxom1YEDlRv94+Wb8E0tSkLwdqy2fnvG IQweAWHMuF7WbS0ozfef1RKL+42uL6H0WToEjLqJsa2dyrIOJOMG519Ydry7X7Bl+cg7 oEfQQOk79K8SVz08bxegLvZXXVWROaIOqN2Cjln+b0LDblZef/TJAyKRU8Qq/PUF5sTb 4BWa+fSlFjP5coMvX/voMJ/qcktI7ckTeTOztCscL7YIKDL1AD5bCK+7VaaMgmNo0PNB iIYZBOqH3cGYakMaH4pqtLgYShTikHz3SxpRBhfiWzPqrNexf3G2ON3SYGnKny7e40Ju k5Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=c7MkMWKFtmiiVwlpdWYeE/xiL6bpeZSYnEXl6lxBbgE=; b=cPpv7UeRDFLIMZRXvJR+C6tumgwY7auSxlsv7sMnVTuwjy7mW2SUtdrM1w7FSfB3Xs zq2HkDA5cuM6DcDC3xekn9AoZZySKWid3eW/ZU9a5rQO9QivUgMv/Dg7hU5Ud1eVn4TD l4snRWgnv3GIFLbHdVMMIfWnxqBpgOFxPlKT8iPF/w4iY68c2jlblHRUzJuckKIZDESA 5IZu3sMES3mX6E6RIRRM4kyKJKjz/BqC3PSAx8vmqzxVXG0L6YWCNMD+p8lEie/YvQ0+ bxHCv3t8zTPl/Z8Ga9QobULDGRD6LI3noSmnLVSp/80CjWx2GFUHxYDj1fWK/fxMyHaw fkjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ukjO1KdF; 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 m12si21532799jav.104.2021.06.01.23.43.01; Tue, 01 Jun 2021 23:43:14 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ukjO1KdF; 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 S230153AbhFBFtv (ORCPT + 99 others); Wed, 2 Jun 2021 01:49:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbhFBFtv (ORCPT ); Wed, 2 Jun 2021 01:49:51 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C55EC061574; Tue, 1 Jun 2021 22:48:07 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id b15-20020a17090a550fb029015dad75163dso1110357pji.0; Tue, 01 Jun 2021 22:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=c7MkMWKFtmiiVwlpdWYeE/xiL6bpeZSYnEXl6lxBbgE=; b=ukjO1KdFh+9m9UoJKbxNcsYRNDPpYljr/9FC0nsfh7rt4wChNgtZLryyJELpWTYcuR KPdiz+CJ3ygtvoZzd97ZErBx/W34yb6Ryq8m+x+4EyZvPh321o+8HMxePenhqpStVXz7 vL/TOzRUtH0gxeJrzftIu3hbXmb5AzZf8vYchlfRoyQdplMvbQp+rjMAkxEe5k4sSlq3 51fXE87RXeUMAfhrUaPgJ2ZLxl7CnG9WhKLBb9i5w3uthAp3f3bv7Us6qiRlJq14edZm orQwOja8ddzJ7TU+AMx9KHwtD/rapUAGaptnzpO/Ed94lyZJt0TSp7BtYpRn2smWuJE0 Lrnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=c7MkMWKFtmiiVwlpdWYeE/xiL6bpeZSYnEXl6lxBbgE=; b=lHnag4PS9uFdbzutDOqp3CzX5FVIx37OIruVhDQAo0qZ4BQiKTSs7Q8UcpJHoq3QUH ABjDdaBcGxZEIqre98tqV1sXTVdaEjB/0JWW3u8IKO775zxz6w4MaUmu1acBrMyo5qwe 3QqCWjwYQTCasqUpA2y2/RoH3oW8mSg+HcSKrGs8Y9XZ0jjUFgHmRygLRhs5Xt986VVn tuDRrjlBhJ5khK0ntXN7AikXEncIz7EoaKoPq7JhVjnzJ/eXp03lwt/twdkuqck6J10J Y1RysEAoVrzLfVuUX6H+rggSy6PsmQLQeXnG0DWE1i0subdAwienR33AOVRSn6iW83z3 wZEQ== X-Gm-Message-State: AOAM533AAFgLs5mUNbkrL3HtY0078cRR9uQkKiBHQesHH07XIxrH/cQg 6WeMdfNe0Qs5UHybNn66UG4= X-Received: by 2002:a17:90b:234d:: with SMTP id ms13mr5410642pjb.135.1622612887022; Tue, 01 Jun 2021 22:48:07 -0700 (PDT) Received: from raspberrypi ([125.141.84.155]) by smtp.gmail.com with ESMTPSA id n9sm14835961pfd.4.2021.06.01.22.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 22:48:06 -0700 (PDT) Date: Wed, 2 Jun 2021 06:48:02 +0100 From: Austin Kim To: paul@paul-moore.com, stephen.smalley.work@gmail.com, eparis@parisplace.org Cc: selinux@vger.kernel.org, linux-kernel@vger.kernel.org, austin.kim@lge.com, kernel-team@lge.com Subject: [PATCH] selinux: remove duplicated LABEL_INITIALIZED check routine Message-ID: <20210602054802.GA984@raspberrypi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The 'isec->initialized == LABEL_INITIALIZED' is checked twice in a row, since selinux was mainlined from Linux-2.6.12-rc2. Since 'isec->initialized' is protected using spin_lock(&isec->lock) within various APIs, it had better remove first exceptional routine. With this commit, the code look simpler, easier to read and maintain. Signed-off-by: Austin Kim --- security/selinux/hooks.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index fc6a3ab7e179..a236b0a33665 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1448,9 +1448,6 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent struct dentry *dentry; int rc = 0; - if (isec->initialized == LABEL_INITIALIZED) - return 0; - spin_lock(&isec->lock); if (isec->initialized == LABEL_INITIALIZED) goto out_unlock; -- 2.20.1