Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2211423iof; Tue, 7 Jun 2022 23:20:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPEt+WG0WJeRvsrUce7m43tvGeFPcE1h77HdqcNlo7ublnlE9VxnknKKbQIYeh9y/BPlas X-Received: by 2002:a63:5b18:0:b0:3fc:9921:f8b3 with SMTP id p24-20020a635b18000000b003fc9921f8b3mr28317600pgb.52.1654669223960; Tue, 07 Jun 2022 23:20:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654669223; cv=none; d=google.com; s=arc-20160816; b=FQ8AxgowZomhK6nf5kyVOkx/oTkFtkX5ESZeTgmfSPMMNU/y81nw5et679yAc6QBAZ pZsyBqIR4waRzBG7EfYcnu+WRP6UlB7PdiEnDWV/fFn0iuoxIHxw2a+2U5AiQifDX/A4 kCIQRxXX+L8XXP+tVi4mOLZsUB2HbmquFUNyAk+Y5ImeO8aiiSPdX2DIVRQn7aAtvty3 GxHx2IKKQxDdZbFUJmUTnATue9MADnUX8e7tnJT26MXAWumGbFEObuIqHPbNTPQmHZKr VpuCkUXh+lFbR+bZE5fffP3sYFVoz8OInID4K9oRAmOnGjUW6FIJ00YKiHaTCRlI6w9g xdnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Cjir8KR4eTFQv2B1Qg4laWUdw2y4mAnsX8ofURivXOw=; b=MylaMG2Pgd3OcerVNi0mQXuQfEb+O93atW9cjr8tv81GH2guUvqnXG5540786UpVCQ qSRypUHW8FcZ7evjxe3ODZIpaRp6R/mjMfXMbe5Ohe6xQXC0m9SMkzU5f44YcwOxuKWM LpfD+rOv/e3d3oDG5cW7OdyTStll9OG+N72XVYD6M24ENLkyHm656oazxCJUEtQgcE+c TN53T7KJE2Hoox9fN62ayc8GSuQSeb2PNh4CJGcktbvp2rm9DUbIQ2X3t3kUWxkIPm0K syg5XBtm43X+jRySDWwWwGGlOnLaXQYL3WW/mnVEfosFHZ/77hUntJihV3EhHLW5r1od gBmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Yg0tPphB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d13-20020a63734d000000b003c5ea42d972si26788947pgn.168.2022.06.07.23.20.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:20:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Yg0tPphB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 855193998FF; Tue, 7 Jun 2022 22:41:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442717AbiFHCBC (ORCPT + 99 others); Tue, 7 Jun 2022 22:01:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1838814AbiFHACL (ORCPT ); Tue, 7 Jun 2022 20:02:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4756C19D627; Tue, 7 Jun 2022 12:25:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CF70560B09; Tue, 7 Jun 2022 19:25:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD69DC385A5; Tue, 7 Jun 2022 19:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629954; bh=uKZth2wW7tJJ3m1gjlFlyDbnJUXr98WnLkj7u8W5GIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yg0tPphB+fdPzd/MI+On1+XKO7bBPpV8Z+G89wdtj9i8CT54gE65DvW9MamshmtU1 XoCjT2TH0XhuEOfXe/mzT6jojSUTLbi/hCxNmhN7qY2sVpYylkciXeVC/RUkH2kaYa dXyfT3eXQ/7VuPUOW6V7UcYyfTtqoFA3sZXSYOTk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, TOTE Robot , Jia-Ju Bai , Coly Li , Jens Axboe Subject: [PATCH 5.18 877/879] md: bcache: check the return value of kzalloc() in detached_dev_do_request() Date: Tue, 7 Jun 2022 19:06:35 +0200 Message-Id: <20220607165028.313237677@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai commit 40f567bbb3b0639d2ec7d1c6ad4b1b018f80cf19 upstream. The function kzalloc() in detached_dev_do_request() can fail, so its return value should be checked. Fixes: bc082a55d25c ("bcache: fix inaccurate io state for detached bcache devices") Reported-by: TOTE Robot Signed-off-by: Jia-Ju Bai Signed-off-by: Coly Li Link: https://lore.kernel.org/r/20220527152818.27545-4-colyli@suse.de Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/md/bcache/request.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -1105,6 +1105,12 @@ static void detached_dev_do_request(stru * which would call closure_get(&dc->disk.cl) */ ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO); + if (!ddip) { + bio->bi_status = BLK_STS_RESOURCE; + bio->bi_end_io(bio); + return; + } + ddip->d = d; /* Count on the bcache device */ ddip->orig_bdev = orig_bdev;