From patchwork Wed Mar 3 12:20:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 392058 Delivered-To: patches@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp5078099jap; Wed, 3 Mar 2021 04:20:55 -0800 (PST) X-Received: by 2002:a19:bd7:: with SMTP id 206mr14603673lfl.318.1614774055367; Wed, 03 Mar 2021 04:20:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614774055; cv=none; d=google.com; s=arc-20160816; b=O4f2WeTVHTMW03jr6r4rvIcFy5LaxjeDJBXwzX26dq0LMNlAxRPKyqYUIcaYLMdUE/ J/m/fgZqYXpWc1+lkvHARuzXcem1xjpFl8xV10f5sRMf1SlFv7rEAA3IS8Ua+m2MP11j yK+DQS1GbIUdtOgRvcRn+OggM9m05wP7EIrIDC+ps7aw4c4OkzP72kG2scotTKuzt9vG UD5AeLehyJQmwWMzTL+F0z4IZvFxTgmlb2nObmK/7Wo2idk3mXQz2RWBBUEP8Zj+5HGY txoyq/f4VkBDupZdqPZ41yOmMHhwUra0h+XCi1SY5xgzzDSyAib85UVByIkt4b7y5p6R Aw+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=soyM9wPlLASUiUbmRQQtsdUjbF417QlwKml+91jIMqs=; b=dJrO8mofHE00GBbxch8oG5xsZgKLK0RdcZHc06/UFpk3TNGiu7uQeXG/lZ9mToFGa1 c7B7qzGyjNhk0hcUFt0oaygY++n3y6gimAcqYYLmEM/sYl/Uj9JVyvkCS9Jot8VgYvw7 CjFLTW5xrH5YvwmQidYAJsnOhd0thBOP7CpHeY0iSBZxVIt/BemtM9acvMxp8X7cqAVG l+e35gCVWi7sq6vjxTKmdd9xRahP3LWx8gYrW1ULQ3Q/oyqDCtL9Q7Q2HYvXDgiDZhRz FFgG76JWCTbJ2Yx13mwwKCqIujc+kHRA17CLHgph9Ta6t7pJ6wdXgd8Yh4o3hExXUgaV hkTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H8fTVYBk; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id p10sor5550783lfu.90.2021.03.03.04.20.55 for (Google Transport Security); Wed, 03 Mar 2021 04:20:55 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H8fTVYBk; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=soyM9wPlLASUiUbmRQQtsdUjbF417QlwKml+91jIMqs=; b=H8fTVYBkdNNsM4NQ2zrh58J24JrxnUp/sbzJz+tslBM2fXthmdZg8PunTTxX5PeqZS wYB0hPGkc8fGLG2e26Y2ceHPXGShqZJ3egDGkhZUZ/fb72ew+VImxGywy/Jb7PiTCliF pW+kFtx3NpztdYl7ku0T3Q0A+CqiXg5nQJ0DIofQX1XrBw82M4XifHsHgHtqZVIF1tFh 96lG5SdY/uKjKkP+p7vcTIpNCU00AWHHGaSNr/9RlrczOeG2/ftzIfZRBarbCI1KI2Vs Zu6roEFOCAYzwiYyRpMY58cJ+d5uzvVprYR7BFzeOsJTBJnANQkM+jZJEMgbix0QKwvx MyOA== 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=soyM9wPlLASUiUbmRQQtsdUjbF417QlwKml+91jIMqs=; b=T604dwBqwZ30d/znsr8Gadp0xm636lXbe2yokYhiFcHF9zIasDgdoapJgsH7LtpCbA Aogflm0tv5EkY6X91Ss7RtwqCJGltH8gmy8rtZfW42y/5nEHF3GOe+0G/TiYBw2iNoTT KvLnQEL5Q+lWf1DKUx9R6c5w6/N2AGTQI6G9bZD67+KRKkACsz3YJmDejSgPp+qFypuE 0r/Pz9i+fi8IQDO4/W2ZVvx5kqKB8y7K9i1nE5F2UHrzkBpj16+fVLEkyGIAVYa5ukUK J7D+ApYAKzmYoOJ53tmLDx101KDs24a1FKAKIFOw2rfj4cyZ76LxpqouLW4ufhtwLvJr KayA== X-Gm-Message-State: AOAM531wHzvcF67gWsxEHUjQbU6I8GHS2tDE4WZbWGD7qz+5n3mGveKo 8qAVdt6j8h4cy44DmYyxowKX1UeB X-Google-Smtp-Source: ABdhPJxhQ8IEPAejaPoXzG/IU+//OTOpt03Evjcamw7wzwgLwru5/CGFu9Rsa774rOsyYUKUJqMmIA== X-Received: by 2002:ac2:5e21:: with SMTP id o1mr14773513lfg.435.1614774055042; Wed, 03 Mar 2021 04:20:55 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-155-4-129-234.NA.cust.bahnhof.se. [155.4.129.234]) by smtp.gmail.com with ESMTPSA id d3sm811519lfq.249.2021.03.03.04.20.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 04:20:54 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] mmc: block: Drop use of unlikely() in mmc_blk_probe() Date: Wed, 3 Mar 2021 13:20:47 +0100 Message-Id: <20210303122049.151986-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210303122049.151986-1-ulf.hansson@linaro.org> References: <20210303122049.151986-1-ulf.hansson@linaro.org> MIME-Version: 1.0 mmc_blk_probe() isn't a hotpath, which makes it's questionable to use unlikely(). Therefore let's simply drop it. Signed-off-by: Ulf Hansson --- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 8e6a623b35de..dc6b2e8f4f95 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2888,7 +2888,7 @@ static int mmc_blk_probe(struct mmc_card *card) card->complete_wq = alloc_workqueue("mmc_complete", WQ_MEM_RECLAIM | WQ_HIGHPRI, 0); - if (unlikely(!card->complete_wq)) { + if (!card->complete_wq) { pr_err("Failed to create mmc completion workqueue"); return -ENOMEM; } From patchwork Wed Mar 3 12:20:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 392059 Delivered-To: patches@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp5078119jap; Wed, 3 Mar 2021 04:20:57 -0800 (PST) X-Received: by 2002:a19:ae07:: with SMTP id f7mr15414032lfc.551.1614774057194; Wed, 03 Mar 2021 04:20:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614774057; cv=none; d=google.com; s=arc-20160816; b=xwh9oXYiVMUXG5JisokpXZNHSEqa7ujFCmOT9MHalPCKFfTZu/SVuGaunAdibVT+EV 0N4JGeEuHo/ddSl0w1L2/4MxwHQZYdf6F6VmI1uw3bT2/dnDZeCPGwffl2qsIWOhkYem xbdUzNTp3PlDCH1mldNoOet+cntpNGMjBsJA+LwQA4+es4+tIBC2VdsSX27ybaHAAcj5 z5ncsyEmrAeMNjoNQ5P66Zf1ImUSGE8R4qA39NMV8C2chsgYdmSrjY02UMLEPgJHvGsF qGNMFeGWlnBoaHQl6vB/FcfbddYJCleFgOszYzmgj2PHw3L1assGPRUT9XTN87TdsBCZ l5yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Vf8w2DOx9jzNzEvSal2fcDgyCGSYzKizUYKhFMSZIWY=; b=j9allkqT5RcP7MR8KuOM/GNQ+4q9UD3mh4QM2bxD0BUHY3ApoJ/fMvjnLTosKqCQYa HFn8zacZBmU0qwWOESM3ltVxgNeL7YwJMIHVpzPcsQ8Smoq/23XdM3zcYB30ySwHe9vy KpVXKDWaiK9PUYFwjg0BLQrXzGZ7xWLrWm3b0CM71vQFyrDbClGSWmzUkjXOUIa8ymNs ZxA2KfX6pklT3prwlmrtVBIAyyWWT5F8drAuWFfoU+KqNTytLpKvmAoiWBT0E5+pG/PU EjL7Tu5Wm3E+trejWmUDQDTP3YdiKrZKDxZ6OGwT3Tqc1zHUhBXKv0uNYJy8z357o9d8 qu2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b+YOBur+; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id d14sor5827930lfg.134.2021.03.03.04.20.57 for (Google Transport Security); Wed, 03 Mar 2021 04:20:57 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b+YOBur+; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vf8w2DOx9jzNzEvSal2fcDgyCGSYzKizUYKhFMSZIWY=; b=b+YOBur+UNT3fr1MydkfahrEEu0JFWr+GUvB+DTkjYwK3771dYvme0s6U/30Qq2qVU aGyBROFh+WGe8PSdgsVYxWFKg/xBEe13a2dYCdKNBCdPhAKCNjgUNl97HkNkwNZluNMB 9jXhYjoCW8IRDeNORW4rAqeKcEnNtUGSVw2Rer0Utm4lRD/wkuX/Jwiji31TkuBx7xm1 b9N+DmuUo0YQWje6iiV0e9loryhhKnXDI0Fcgy9csg4UgsaeIPANALzEQi5g7SPKzkuC Uqi6y1VTOsGtTrdsxUqLWAKM0zy+v/tx1OCd3GG5hoE2kux5vbGhKOqUC/xB/r5JQS8T dw2g== 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=Vf8w2DOx9jzNzEvSal2fcDgyCGSYzKizUYKhFMSZIWY=; b=IiHqFYV4xkZLUKWbK3pYY5UGhrFMEOZhuKdkyp/nqFyJBdcjCEBLNCxhOafKeWkxuF it911LwqjsQAVmtvBoSUqUaY9O/L5lPpkZowvnRDMU/XIln9rxtGbiEbHWHe7sozX6Hl BgmqTPdTSqNlHc5c21H6aJThwNAlBahZbYfVMNlMRLKIwy7xuZSZmktMGroTP8eHhr5p t+V5H0i7/p0NcgEY+0VwXyRozsdzAd4YwE1enAZW2hCZuSEmuyCEc3ucyubsHMHg84/3 diGfYKOXenaomUYcRocUWad8RcuMtnBYDDJQxYtk0p+aFBCxMrpA7GqspgdEvNMwVUI+ qu2g== X-Gm-Message-State: AOAM531gDFtSUO9SBC4iWUl6O5fzjqWd2SUQL7hQimwLUSyMPJESrGm9 rb5bjIGsEufkScVeAbaVLBbHNMv8 X-Google-Smtp-Source: ABdhPJyejyZYo5gNNlhWEICEam/nrx5cNRlHDqbjVPosD7259wOXYQnbJgEu1XQs1VsA48M6VuUiPg== X-Received: by 2002:a19:4101:: with SMTP id o1mr14056347lfa.16.1614774056786; Wed, 03 Mar 2021 04:20:56 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-155-4-129-234.NA.cust.bahnhof.se. [155.4.129.234]) by smtp.gmail.com with ESMTPSA id d3sm811519lfq.249.2021.03.03.04.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 04:20:55 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] mmc: block: Simplify logging during probe about added partitions Date: Wed, 3 Mar 2021 13:20:48 +0100 Message-Id: <20210303122049.151986-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210303122049.151986-1-ulf.hansson@linaro.org> References: <20210303122049.151986-1-ulf.hansson@linaro.org> MIME-Version: 1.0 To simplify the code, move the logging into the common mmc_blk_alloc_req() and drop the rather useless information about the partition type/id. Signed-off-by: Ulf Hansson --- drivers/mmc/core/block.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) -- 2.25.1 diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index dc6b2e8f4f95..39308b35a1fb 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2261,6 +2261,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, { struct mmc_blk_data *md; int devidx, ret; + char cap_str[10]; devidx = ida_simple_get(&mmc_blk_ida, 0, max_devices, GFP_KERNEL); if (devidx < 0) { @@ -2365,6 +2366,12 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, blk_queue_write_cache(md->queue.queue, true, true); } + string_get_size((u64)size, 512, STRING_UNITS_2, + cap_str, sizeof(cap_str)); + pr_info("%s: %s %s %s %s\n", + md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), + cap_str, md->read_only ? "(ro)" : ""); + return md; err_putdisk: @@ -2407,7 +2414,6 @@ static int mmc_blk_alloc_part(struct mmc_card *card, const char *subname, int area_type) { - char cap_str[10]; struct mmc_blk_data *part_md; part_md = mmc_blk_alloc_req(card, disk_to_dev(md->disk), size, default_ro, @@ -2417,11 +2423,6 @@ static int mmc_blk_alloc_part(struct mmc_card *card, part_md->part_type = part_type; list_add(&part_md->part, &md->part); - string_get_size((u64)get_capacity(part_md->disk), 512, STRING_UNITS_2, - cap_str, sizeof(cap_str)); - pr_info("%s: %s %s partition %u %s\n", - part_md->disk->disk_name, mmc_card_id(card), - mmc_card_name(card), part_md->part_type, cap_str); return 0; } @@ -2558,9 +2559,8 @@ static int mmc_blk_alloc_rpmb_part(struct mmc_card *card, string_get_size((u64)size, 512, STRING_UNITS_2, cap_str, sizeof(cap_str)); - pr_info("%s: %s %s partition %u %s, chardev (%d:%d)\n", - rpmb_name, mmc_card_id(card), - mmc_card_name(card), EXT_CSD_PART_CONFIG_ACC_RPMB, cap_str, + pr_info("%s: %s %s %s, chardev (%d:%d)\n", + rpmb_name, mmc_card_id(card), mmc_card_name(card), cap_str, MAJOR(mmc_rpmb_devt), rpmb->id); return 0; @@ -2876,7 +2876,6 @@ static void mmc_blk_remove_debugfs(struct mmc_card *card, static int mmc_blk_probe(struct mmc_card *card) { struct mmc_blk_data *md, *part_md; - char cap_str[10]; /* * Check that the card supports the command class(es) we need. @@ -2897,12 +2896,6 @@ static int mmc_blk_probe(struct mmc_card *card) if (IS_ERR(md)) return PTR_ERR(md); - string_get_size((u64)get_capacity(md->disk), 512, STRING_UNITS_2, - cap_str, sizeof(cap_str)); - pr_info("%s: %s %s %s %s\n", - md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), - cap_str, md->read_only ? "(ro)" : ""); - if (mmc_blk_alloc_parts(card, md)) goto out; From patchwork Wed Mar 3 12:20:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 392060 Delivered-To: patches@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp5078145jap; Wed, 3 Mar 2021 04:20:58 -0800 (PST) X-Received: by 2002:a19:4942:: with SMTP id l2mr14626250lfj.95.1614774058785; Wed, 03 Mar 2021 04:20:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614774058; cv=none; d=google.com; s=arc-20160816; b=eMYshs8JPNlrBGA75b45GbWdkwW0kkvd9eeNaJcghCCzjceqSIp8VpcnGxilRV2oXC Jv7ZGS2whpO8SqhqDNRpjK5R9HhkviVsq7iwoFbjaQm9+/bM7fayGCTNpADgrEc2PrCw OpGkVuRRBcyqKS+hP+lo3gUWh9+ajRbkQSk9Ttb1cqSMwj8yz8Q4PyWDdJlXnmP/Rtb5 EHSY02NSQvdzoSIacbpKuAmR7qTBDo11093t48zm6CcUf86pSKmKoU67zEVlntrbOm92 6QU2q8bzusuUI6hEDFDbu7kyJV/Nna7SnOp+hEykJuS52FTf0kmgam2cumkMSsSvEL99 YS/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=lD9APgZ2jhcnYCgOIeOpXqVPb3v1Goo0x0OpO8dXVPQ=; b=xwk/9AKPEFPJENX+rSNjfvkHMtFj6G6Y48ycSJ7vWupknHSzv0KJ77lUO7Fsunie/m ZkXgbfTpZ6OrjilxW40uaqskiMtc3x+wQeub6h50/1ebTAeIc/kw098ZvkeEXkikMFUq SuXlO1n1dSJ7YtH37ObGs8xGtO0qKYvZf6xRYKaF3S3n3QIKdB8So91ov0yqaQzkvv6x o80FR2Ozj0M7/iA0C8MpLwpuStNtRbJhL1tVVaP+0d/a+PYx4Roe3lOZe33F27Xcjv9D fmBXk4E5XaLp7JBl7cjxKZW9Ikaua4FSc4I60RZ/CUTgpQe92CDRbLgkGCebYbbj7Uyt HHhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=esW4B307; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id n4sor192403lfq.85.2021.03.03.04.20.58 for (Google Transport Security); Wed, 03 Mar 2021 04:20:58 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=esW4B307; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lD9APgZ2jhcnYCgOIeOpXqVPb3v1Goo0x0OpO8dXVPQ=; b=esW4B307jxAwSGPOl0hNyuol71pvJKogmDuDaPA54yUJHJrM3nvwlFIuL76Nlwalq/ JWvdwuMpCdt6kJxkcvncGDud3z4yWyIU7w7upwmK2SfZ8BzGT4KxzUKEwDLGDK4NgMBD Dyg1n8aN5Bf+NI2Gdd8qNo7LLBPs+v6oYG77/Md9QOtMh0VmEoXipcjlg9v1keeTWI46 XvKBEgV5v/mm1zCgpyBcHhed7kEXdyNW3s2Jv8amuGzPWPI8sZgu6I/H3mVejToMTd4Y egFkwDlKjBvoQ9mGdiauhpLF9mOAnYEL69HP+kh6FlQivqEqHerwiqVP3RpLgece0tU8 1M+Q== 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=lD9APgZ2jhcnYCgOIeOpXqVPb3v1Goo0x0OpO8dXVPQ=; b=GklRYjmiBuA2BvhVr4R4U0817TNrDKUdSp8y4gBdSJVFNZDQHBhCZTcS/PZoLelnkh WG1X9iiRQ/tSVYv/JfRXynljoMpFBD8qawUJE0gp2udca6nU7l74qsyT8y9XCHr9Iyek GyV7zilZvOb3jLlvyhxfR3dmBj/cwIMrA2XMXhHxzaK/kBYsPb/3gyzZU8XAD3hJrkOe cTQXBNeVGEI+tTLz7eWfWQrOqXMnkArPlvUOuxUi642vfqrL4mZMDDKLHrNoQHSiBdvr wHwfTIPramBAmp+bEOerTqeh0NDjDiovOoPzDCps+7AGfj6CE/B69Z7xatmZ86C2NS2j VCYg== X-Gm-Message-State: AOAM532M8V69YaT/oiCKFjfYqchd2PZFpbdAJfCbLhqt5kill31RS0Px B+EdSKU6mx14E9+EgtnLq4KgCXsTgEQ4lbjC X-Google-Smtp-Source: ABdhPJz3ZN1+8FheWJZpyLBpnGV/RnMW3VOVx9DzzJOy9r0WPzdCqF3RuL4kdnjCbeNNFO44GRKE7w== X-Received: by 2002:a05:6512:3055:: with SMTP id b21mr14618790lfb.356.1614774058409; Wed, 03 Mar 2021 04:20:58 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-155-4-129-234.NA.cust.bahnhof.se. [155.4.129.234]) by smtp.gmail.com with ESMTPSA id d3sm811519lfq.249.2021.03.03.04.20.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Mar 2021 04:20:57 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] mmc: block: Fix error path in mmc_blk_probe() Date: Wed, 3 Mar 2021 13:20:49 +0100 Message-Id: <20210303122049.151986-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210303122049.151986-1-ulf.hansson@linaro.org> References: <20210303122049.151986-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Returning zero to indicate success, when we actually have failed to probe is wrong. As a matter of fact, it leads to that mmc_blk_remove() gets called at a card removal and then triggers "NULL pointer dereference" splats. This is because mmc_blk_remove() relies on data structures and pointers to be setup from mmc_blk_probe(), of course. There have been no errors reported about this, which is most likely because mmc_blk_probe() never fails like this. Nevertheless, let's fix the code by propagating the error codes correctly and prevent us from leaking memory by calling also destroy_workqueue() in the error path. Signed-off-by: Ulf Hansson --- drivers/mmc/core/block.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) -- 2.25.1 diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 39308b35a1fb..02b656305042 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2876,6 +2876,7 @@ static void mmc_blk_remove_debugfs(struct mmc_card *card, static int mmc_blk_probe(struct mmc_card *card) { struct mmc_blk_data *md, *part_md; + int ret = 0; /* * Check that the card supports the command class(es) we need. @@ -2893,19 +2894,24 @@ static int mmc_blk_probe(struct mmc_card *card) } md = mmc_blk_alloc(card); - if (IS_ERR(md)) - return PTR_ERR(md); + if (IS_ERR(md)) { + ret = PTR_ERR(md); + goto out_free; + } - if (mmc_blk_alloc_parts(card, md)) + ret = mmc_blk_alloc_parts(card, md); + if (ret) goto out; dev_set_drvdata(&card->dev, md); - if (mmc_add_disk(md)) + ret = mmc_add_disk(md); + if (ret) goto out; list_for_each_entry(part_md, &md->part, part) { - if (mmc_add_disk(part_md)) + ret = mmc_add_disk(part_md); + if (ret) goto out; } @@ -2926,10 +2932,12 @@ static int mmc_blk_probe(struct mmc_card *card) return 0; - out: +out: mmc_blk_remove_parts(card, md); mmc_blk_remove_req(md); - return 0; +out_free: + destroy_workqueue(card->complete_wq); + return ret; } static void mmc_blk_remove(struct mmc_card *card)