From patchwork Sun Apr 19 19:45:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11497871 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0CF0714DD for ; Sun, 19 Apr 2020 19:46:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D6CD52145D for ; Sun, 19 Apr 2020 19:46:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6CD52145D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 79B178E000F; Sun, 19 Apr 2020 15:45:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 639CF8E0003; Sun, 19 Apr 2020 15:45:53 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5289F8E000F; Sun, 19 Apr 2020 15:45:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0077.hostedemail.com [216.40.44.77]) by kanga.kvack.org (Postfix) with ESMTP id 33B9B8E0003 for ; Sun, 19 Apr 2020 15:45:53 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D017E2C89 for ; Sun, 19 Apr 2020 19:45:52 +0000 (UTC) X-FDA: 76725634944.18.steam95_506b079dd4933 X-Spam-Summary: 2,0,0,33103fbabf2f591d,d41d8cd98f00b204,mcgrof@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1539:1711:1714:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3350:3867:3868:3874:4321:5007:6261:10004:11026:11658:11914:12048:12297:12517:12519:12555:12895:12986:13069:13311:13357:13894:13972:14096:14181:14384:14394:14721:21080:21444:21451:21627:21990:30012:30054,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: steam95_506b079dd4933 X-Filterd-Recvd-Size: 3422 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Sun, 19 Apr 2020 19:45:52 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id kb16so3603129pjb.1 for ; Sun, 19 Apr 2020 12:45:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JI0MWD+QJRNLm9H/ySGaj7rD32bWrmPpBuBR7vXM0po=; b=VklOt08b9Us3RWINtDOh2UpB4veGxfep2UvBVvp5x8/Okg0EtwW3hvyC7wLnECdnLl 2PSYEbsvaN6WEIyga11/Ic8hV2zx16bluy5qB3Mg9BI7pZSj5LffLQEfYQG1Nf+RCBsQ psqFS6ZeLZdRl4AJmO2IdD8IdNfS9JEkw+mj5kEjgTAm+ccWDaAaDkMtHlqfFV0nGPo6 w1vr6RZfMZVlT2GcWJSqKJrrkV156eoqxUhLTLcM5fIliYv8X3yb0RzZWSLXh673QLeW BmPLTToGf5oegtdveR3NQoiq1Vj2RzgoNRlnz7MN66J8hJXLBShtF0Gb7FW8H6upWffU iFhQ== X-Gm-Message-State: AGi0Puaukn6qU1ShEvd/YwtOeTMt2ZghyjzTbMtTucnBPBGyoUSPjZke fU4iZSUUAvEa1bNiArtn9CI= X-Google-Smtp-Source: APiQypI5CAO7B1a2nLDOtdLnxkI6y2BKcHcPj3NYYswPtP9sWC/TtH2DZACqpYblnpzrNGt00D3cQA== X-Received: by 2002:a17:90a:b10f:: with SMTP id z15mr15705940pjq.188.1587325551767; Sun, 19 Apr 2020 12:45:51 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id 1sm4588pff.151.2020.04.19.12.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 12:45:43 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 1D0CD42309; Sun, 19 Apr 2020 19:45:39 +0000 (UTC) From: Luis Chamberlain To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bvanassche@acm.org, gregkh@linuxfoundation.org, rostedt@goodmis.org, mingo@redhat.com, jack@suse.cz, ming.lei@redhat.com, nstange@suse.de, akpm@linux-foundation.org Cc: mhocko@suse.com, yukuai3@huawei.com, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH v2 10/10] block: put_device() if device_add() fails Date: Sun, 19 Apr 2020 19:45:29 +0000 Message-Id: <20200419194529.4872-11-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200419194529.4872-1-mcgrof@kernel.org> References: <20200419194529.4872-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Through code inspection I've found that we don't put_device() if device_add() fails, and this must be done to decrement its refcount. Signed-off-by: Luis Chamberlain Reviewed-by: Bart Van Assche --- block/genhd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/genhd.c b/block/genhd.c index 06b642b23a07..c52095a74792 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -721,8 +721,10 @@ static void register_disk(struct device *parent, struct gendisk *disk, WARN_ON(ddev->groups); ddev->groups = groups; } - if (device_add(ddev)) + if (device_add(ddev)) { + put_device(ddev); return; + } if (!sysfs_deprecated) { err = sysfs_create_link(block_depr, &ddev->kobj, kobject_name(&ddev->kobj));