Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2055860pxb; Fri, 25 Mar 2022 10:18:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxV7Xw5yjX0pcF0oLkzGV/eUnSehU4Arq2PPx0EiKDriO4dDTkvXBuRMH2RpdvK7DiH/es X-Received: by 2002:a05:6870:462a:b0:dd:f4f7:24be with SMTP id z42-20020a056870462a00b000ddf4f724bemr5528913oao.39.1648228690271; Fri, 25 Mar 2022 10:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648228690; cv=none; d=google.com; s=arc-20160816; b=FbY6UKrdD+mnV/3kk/MUHa9K7l2zcv7eW3ieFq0Vqs1yi/TKjBUektADkArm+iQP+7 IVhg6dPFen5LK1exLFY4eeAdZdjFyS2FT546VMXhITJ5M5szTWPSc1KYZ6xPj0M0giMu 9df/cpxRIWlLSc4b/XaJ7l5NLP9ZPezxX0kCd4Xl5f5PdaaFbYIAPlQpnSzJRk588cc+ owUeE85EPZJoSe9tL1Jh0bYrAQ1ty0Uwt4OcIiJM8VreO725ZouzLn2+Ce9YMzKopd4y 6wTMpIT2TP8m6ALIfE5XVjYbJjg345xnhI68KeLXJID2+FN2JaYP05cWuIv+S3A94D/i A6zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=XWiAQ+Z5d0xuLBcjwwQPEKbQplidblsEpe/wGww446k=; b=kWflVtT6u1oNmSksZL7p7INmzQZ7NljF4hNnZe0wYeQATYa+8dDfxnM2oPu6JdGfST Lqr8WKlx6/vJz6X+k6gFAOtktCGgfXidsRzzfjlUrT7swWkdWLTYeOSRLBoztQpB+FwF 0HXUjG1N9XOQ9O5kDr08fYkXBHHMLm6Pvxy8RB739RkxGSvoN9+pwSMF3Y1qk//Wib+b QIMcOocKNtTEqHucLx7FjYPE1uG9kLjZtaC9qD8ZRrQl4J2VCJT5IVMuM0jZhKjiYgdH u5ZuCv3AIx/oDeh0UE/DNKirK/NQBT6YvgrV/byAmWGGZCU/3r6Oni+XwNNoGQAQ1haF X4WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=BWCufjrB; 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=163.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id w17-20020a056830145100b005cb2fc1380bsi2101708otp.135.2022.03.25.10.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 10:18:10 -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=@163.com header.s=s110527 header.b=BWCufjrB; 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=163.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 60EB6EBB98; Fri, 25 Mar 2022 10:17:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347446AbiCXJ3f (ORCPT + 99 others); Thu, 24 Mar 2022 05:29:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240807AbiCXJ3e (ORCPT ); Thu, 24 Mar 2022 05:29:34 -0400 Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B35645D19B for ; Thu, 24 Mar 2022 02:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=XWiAQ+Z5d0xuLBcjww QPEKbQplidblsEpe/wGww446k=; b=BWCufjrBPVlhGS5mk3IwvgOK1Td0q6hxUi jnLEM+Z+ZiaJ+1Ku36v+rlg9aicj+DvTUYXRScdDkakNnGdoWuLu3PI9Y5/Wo6DH haRBevkUFsHnYfaIQgiigB8sDXrdsCpwSDrKurXijJQNJhwiRST9/JXk8CPeBl82 QfhgxNrUM= Received: from localhost (unknown [159.226.95.33]) by smtp9 (Coremail) with SMTP id DcCowACHeGSbOTxiqb57CQ--.3994S2; Thu, 24 Mar 2022 17:27:55 +0800 (CST) From: QintaoShen To: colyli@suse.de Cc: linux-bcache@vger.kernel.org, kent.overstreet@gmail.com, linux-kernel@vger.kernel.org, QintaoShen Subject: [PATCH v1] bcache: Check for NULL return of kzalloc() Date: Thu, 24 Mar 2022 17:27:54 +0800 Message-Id: <1648114074-10045-1-git-send-email-unSimple1993@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: DcCowACHeGSbOTxiqb57CQ--.3994S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrtw4rury5Zw4fGr4DCw17Wrg_yoWfJrb_W3 WfZrn2grZ0kr1IgF42vr13XrWUta1DZF9YvFsxtr1Sqasxu3Z3Wr10vr45JayfGFWrZay7 Z34UJw1fuw1SkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7VUUPrc5UUUUU== X-Originating-IP: [159.226.95.33] X-CM-SenderInfo: 5xqvxz5sohimizt6il2tof0z/xtbBdRvNH1aEB0SbYgAAsU X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 kzalloc() is a memory allocation function which may return a NULL pointer. Therefore, it is better to check the return value of kzalloc() to avoid potential NULL-pointer dereference. Signed-off-by: QintaoShen --- drivers/md/bcache/request.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index fdd0194..232ffe3 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -1105,6 +1105,9 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio, * which would call closure_get(&dc->disk.cl) */ ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO); + if (!ddpp) + return ; + ddip->d = d; /* Count on the bcache device */ ddip->orig_bdev = orig_bdev; -- 2.7.4