Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2338194ybz; Thu, 23 Apr 2020 16:17:46 -0700 (PDT) X-Google-Smtp-Source: APiQypL70OtDI/jAAdxraOuThCLlXqzdJw0HDQLYxL0X0BW8PioYpEiChrHg8sl2fooT8OVVR9k/ X-Received: by 2002:a17:906:2443:: with SMTP id a3mr4500830ejb.291.1587683866696; Thu, 23 Apr 2020 16:17:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587683866; cv=none; d=google.com; s=arc-20160816; b=wGfFp36d02zetTebp7VVy0KtbYbtF+Yi/Wq38x/2tH+EWAgAJC/MkWBfeUB5O0BTpg eLGfL+QNH07yFjXQ59aBlx3JRl5KKbvmyAtGeaaNkw19aiuK4/39m11wEs4K/FobzhL/ DtcESlrouvXAAuEC4q5Okk6pNeZ8SDA58hcPHTc8ISZEA0fSNCgUWg7iv7uw7H1+v+e0 c18wWaGAzmeJRf9fy02i+dDD58Ml8rHw7B8kmi8oI/72+D107mj1WXN7LNh+NZZvKZ65 0fL7AHXV6rhLTk4FRBkohp0OX9GbBsWmtr1rS4McuLHMTgBn3ixqivtgnCjmLVIwT10P GxPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=TuOu/AcNC3rQli8ASJa9r/vb62HoajEg+3MZNA7kw/k=; b=TBEWccMNAVAjDzq9jgzpHwX7POPzpCNgXnmaCIISDCKUXye3q5NV2gaoIAH37OSE9p 2NRvxUpNZnlO7TuAq7/DKe9/zht7Z+janqzYlUcfGfBVhroQ8Vw0SQTZ8UPgUgZIzaof O18uDogNOwPnDuTbWA4TRVP3fVHrXQOdc1Wif9pL4GsgKc1SF3e3/qvP+u7dy0OU9Fqb Oq42QyTEOz7y+h5RYuq6b1foM40YR/9Tu7m0mNaw1cH4+JulPrfNLQw37k/qKJ/1iyNM 8UqYpnaBAHYJ7gWuSGlZcmqPEKlM1c+Igiybnb7I0qDMbcW6nuDSaK6jkhoOj54TyeuZ uOYg== 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 a41si2005162edf.489.2020.04.23.16.17.22; Thu, 23 Apr 2020 16:17: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 S1729044AbgDWXOQ (ORCPT + 99 others); Thu, 23 Apr 2020 19:14:16 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49910 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728466AbgDWXGt (ORCPT ); Thu, 23 Apr 2020 19:06:49 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jRkvV-0004id-C1; Fri, 24 Apr 2020 00:06:37 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jRkvS-00E6s1-QP; Fri, 24 Apr 2020 00:06:34 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Greg Kroah-Hartman" , "Jens Axboe" , "Jan Kara" , "Tejun Heo" , "Bart Van Assche" Date: Fri, 24 Apr 2020 00:06:24 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 157/245] kobject: Export kobject_get_unless_zero() In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.83-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit c70c176ff8c3ff0ac6ef9a831cd591ea9a66bd1a upstream. Make the function available for outside use and fortify it against NULL kobject. CC: Greg Kroah-Hartman Reviewed-by: Bart Van Assche Acked-by: Tejun Heo Signed-off-by: Jan Kara Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ben Hutchings --- include/linux/kobject.h | 2 ++ lib/kobject.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -107,6 +107,8 @@ extern int __must_check kobject_rename(s extern int __must_check kobject_move(struct kobject *, struct kobject *); extern struct kobject *kobject_get(struct kobject *kobj); +extern struct kobject * __must_check kobject_get_unless_zero( + struct kobject *kobj); extern void kobject_put(struct kobject *kobj); extern const void *kobject_namespace(struct kobject *kobj); --- a/lib/kobject.c +++ b/lib/kobject.c @@ -581,12 +581,15 @@ struct kobject *kobject_get(struct kobje return kobj; } -static struct kobject * __must_check kobject_get_unless_zero(struct kobject *kobj) +struct kobject * __must_check kobject_get_unless_zero(struct kobject *kobj) { + if (!kobj) + return NULL; if (!kref_get_unless_zero(&kobj->kref)) kobj = NULL; return kobj; } +EXPORT_SYMBOL(kobject_get_unless_zero); /* * kobject_cleanup - free kobject resources.