Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp630057pxb; Wed, 3 Nov 2021 09:43:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnU7VDlIWC15O8IajmE1BM1MRYqXaPZbfdkbea6e39Fq7G2devuYES1xpTEM+j1Y2YAo/U X-Received: by 2002:a17:906:974d:: with SMTP id o13mr27589826ejy.105.1635957798626; Wed, 03 Nov 2021 09:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635957798; cv=none; d=google.com; s=arc-20160816; b=yNNLseJ3+TcSQx2BwnSKchAxSS8UNiy7UeX+Tkyu0Z2QigJmkwglSyh9YxVfj+vGLg SI0QWidH6qIg0YA6y/Kb7zJcDtsybMFA7c8qk8l+6NUzP+OwvYEVqo2SedoYFalB1ID1 qVjwWovrX7tTpj6KJRv68gO/ac3AjfVi1RK0StB617ivGBLOrD/23OMbcA4QFDWR/zc5 OK+hX3wP6Wb6zoXV0UY7wsJjPLepp/XtxXBgG21gBohCPe7RNVB4dKULnrcBzsaK4eOw ZfyRQnsud0Tjgckaj6LSEzSAM7zsiDwce8ukdohf+eKzkibbT2Kz/w+CLVH+23AlofFn wRXw== 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=0qrxHNDIFk+edOnwg1RDygcWfmb5ExZeJL85X5Z4aFk=; b=QA898ghY+rnl1wNz//Vnnrhs6J1oRzQD1UXcqSdzCnbKMdnSblERyCKcj0pOfW+AW4 a1BZWQMGQldSGkylFFA5g/YVoeTmqXkpwGsaHUc8fXr/cMzuun2v3+gZkav4uVHIehmm 3JfVBIkv9qrdMP4/dGiaA2LZ4l7BLbTfFaZzNKBtp+H7zXk+Y7JTS2wQ1OI32k8+MIAF CKZZdfMZ3ZP+f5UgqXxn4Kth5Mo+GxcVhGbzDMNn1/obkSDMW1UlwYGDW74iNbf1L/en q7dnYD6djMusYtcu7u6Vcs4aRzdLuLZv4uULQJOXWT06MIDDRIM1kjPr31v3eaNvihTg wy4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=iJuXfpma; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id js4si6056528ejc.702.2021.11.03.09.42.52; Wed, 03 Nov 2021 09:43:18 -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=@infradead.org header.s=bombadil.20210309 header.b=iJuXfpma; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbhKCQnL (ORCPT + 99 others); Wed, 3 Nov 2021 12:43:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232883AbhKCQnJ (ORCPT ); Wed, 3 Nov 2021 12:43:09 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6931CC061714; Wed, 3 Nov 2021 09:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=0qrxHNDIFk+edOnwg1RDygcWfmb5ExZeJL85X5Z4aFk=; b=iJuXfpma4uCw5qA5MICtL7C9VR k9BfUV9v5hZfLEKhHTn0Zacyur9jdV8B5eZKtenl1NtgOYzm4Ree6GHKUXOcD+BSHWLnCD3opeJEy CXtXH4Vmjn/qzuJDaT9wFAGpIH8HcwWb5iS9+gbb6UgufuRB0wOiZcUf3qbs7kjPP7jAOD6zrXLAz hBt2/S3hnF6/9G+8TVbdpLEGHKlUDWs13ctDYGRcipkPgNL4Vm2SS6frxytGDhsH5KZsHM2Zg/DXu BbksajzzYhxMukVzyyx+KhUBT8/MuQWGhnqutaV9GPS3s+FUE/SXRHXALQERR+xO+7LF+cYXL2wdZ UmckpeTA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1miJJQ-005oHb-2i; Wed, 03 Nov 2021 16:40:32 +0000 From: Luis Chamberlain To: axboe@kernel.dk, hare@suse.de, hch@infradead.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain , kernel test robot , Dan Carpenter Subject: [PATCH] block: fix device_add_disk() kobject_create_and_add() error handling Date: Wed, 3 Nov 2021 09:40:23 -0700 Message-Id: <20211103164023.1384821-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 83cbce957446 ("block: add error handling for device_add_disk / add_disk") added error handling to device_add_disk(), however the goto label for the kobject_create_and_add() failure did not set the return value correctly, and so we can end up in a situation where kobject_create_and_add() fails but we report success. Fixes: 83cbce957446 ("block: add error handling for device_add_disk / add_disk") Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Luis Chamberlain --- block/genhd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/genhd.c b/block/genhd.c index be4775c13760..b0b484116c3a 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -478,8 +478,10 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk, if (!disk->part0->bd_holder_dir) goto out_del_integrity; disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); - if (!disk->slave_dir) + if (!disk->slave_dir) { + ret = -ENOMEM; goto out_put_holder_dir; + } ret = bd_register_pending_holders(disk); if (ret < 0) -- 2.33.0