Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp661105pxb; Tue, 5 Apr 2022 17:44:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGrciJW4NhLdwuL8uzYd2TzHznPxH1gzlYctNHSvHZx+tbCT0d1AXBQJ0l/337MOIhRv+M X-Received: by 2002:a17:907:7f8d:b0:6da:b3d6:a427 with SMTP id qk13-20020a1709077f8d00b006dab3d6a427mr5753868ejc.509.1649205881573; Tue, 05 Apr 2022 17:44:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649205881; cv=none; d=google.com; s=arc-20160816; b=HThh0a+LEVYMf7suspJ7gP9wpS9lNqMkBeQ7tAGJs4aDm4A7H74kBdjoabS5qI2qSs SKp1nUQXuIyRjnCVun8x8FCaOSv+0cKeZHtzOWUVdvvIiXkGBANRuKH+9eVF+goTgG2G 53uM5Obeu2HeI9xDk8noyFvAXr0TlA5/3CgHqbydKbMJSVnkLkOvC/us9PbzmXsjnbI8 1UUxepgfFtmhJuohWEGMXSiAtrbSH5UUN9Vkif7lBApnDDuPbLUru+y0zBaXBiorZuCi 0hDnCNK9zYXoaRoD6O7BpdmIb26dZlplC8Fi8+utI3IzddysP9wfLFwbwPrdEZ6AJw+l s/aA== 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=OcE3twfUyPWQRT1OCRAtbJ5pwoNp+i5HLiNxwT+Cz3c=; b=jyvkcsUskXjOBQApgJFp7mVcRy+KIzBu3kO/O27si66q81qADHmkznJhZLhj0CZYqK L5U9TbrbCc/Zi1oTcBVapakuTAWwEoS5cyUIZ8FDaJSERLOr0l2XPx29Vft7VmkdsJQo 9tl+GFqBVKJa/sMMHYi/03Kd9s7DVFA+XLSYjYZIaDSPM1zm6eCb5+CSZ6OHGYXMS0cD XgFCO9fXwXmGszL6tH+TLYtkgVbuDZ1W4oYuoOGXoiEinwc3Cltosh7++GIuLwI9+FxS FiXhZ5S+x2aKUz6DPELcRsp92AAOhEXHaeqQ+0ieOaHCs8dprOvTQyqX68E5ugecfLQh IYgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pn+YF36P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay9-20020a170906d28900b006e14834bb6bsi10369139ejb.279.2022.04.05.17.44.17; Tue, 05 Apr 2022 17:44:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pn+YF36P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384280AbiDENcJ (ORCPT + 99 others); Tue, 5 Apr 2022 09:32:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345794AbiDEJXC (ORCPT ); Tue, 5 Apr 2022 05:23:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E12D99D0E8; Tue, 5 Apr 2022 02:12:14 -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 ams.source.kernel.org (Postfix) with ESMTPS id 85C82B80DA1; Tue, 5 Apr 2022 09:12:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA3B2C385A0; Tue, 5 Apr 2022 09:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149932; bh=Y1PEmIAZMnzpISyH6SBsQsjo9DqagN4V+23i6TnvIKo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pn+YF36P/YHALl7dIVHsuby+A8dAOxIXXFc8pGo8Aw7G67CQhQtDrfG8SbuRd9JxC ggYK+9gKuULOfn0XTpuRljGwaYoz6aq0tiMThY56Em+1pVcFte7yOpddAOVrEVCwhX JKJbVAd27fAL4PXHeHG7kryh8HJuQOgwFizA2Tv0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marco Patalano , Himanshu Madhani , Arun Easi , Nilesh Javali , "Martin K. Petersen" Subject: [PATCH 5.16 0894/1017] scsi: qla2xxx: Fix crash during module load unload test Date: Tue, 5 Apr 2022 09:30:07 +0200 Message-Id: <20220405070420.764804490@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: Arun Easi commit 0972252450f90db56dd5415a20e2aec21a08d036 upstream. During purex packet handling the driver was incorrectly freeing a pre-allocated structure. Fix this by skipping that entry. System crashed with the following stack during a module unload test. Call Trace: sbitmap_init_node+0x7f/0x1e0 sbitmap_queue_init_node+0x24/0x150 blk_mq_init_bitmaps+0x3d/0xa0 blk_mq_init_tags+0x68/0x90 blk_mq_alloc_map_and_rqs+0x44/0x120 blk_mq_alloc_set_map_and_rqs+0x63/0x150 blk_mq_alloc_tag_set+0x11b/0x230 scsi_add_host_with_dma.cold+0x3f/0x245 qla2x00_probe_one+0xd5a/0x1b80 [qla2xxx] Call Trace with slub_debug and debug kernel: kasan_report_invalid_free+0x50/0x80 __kasan_slab_free+0x137/0x150 slab_free_freelist_hook+0xc6/0x190 kfree+0xe8/0x2e0 qla2x00_free_device+0x3bb/0x5d0 [qla2xxx] qla2x00_remove_one+0x668/0xcf0 [qla2xxx] Link: https://lore.kernel.org/r/20220310092604.22950-6-njavali@marvell.com Fixes: 62e9dd177732 ("scsi: qla2xxx: Change in PUREX to handle FPIN ELS requests") Cc: stable@vger.kernel.org Reported-by: Marco Patalano Tested-by: Marco Patalano Reviewed-by: Himanshu Madhani Signed-off-by: Arun Easi Signed-off-by: Nilesh Javali Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla2xxx/qla_os.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3896,6 +3896,8 @@ qla24xx_free_purex_list(struct purex_lis spin_lock_irqsave(&list->lock, flags); list_for_each_entry_safe(item, next, &list->head, list) { list_del(&item->list); + if (item == &item->vha->default_item) + continue; kfree(item); } spin_unlock_irqrestore(&list->lock, flags);