Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2263743iof; Wed, 8 Jun 2022 00:49:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylImXI32MYXNAUBSGKi22+BMcl8Z3awMqH3MnctuOs4K13cmNuD2+vKY4tGGogmfoWZcnX X-Received: by 2002:a17:902:a988:b0:158:9877:6c2c with SMTP id bh8-20020a170902a98800b0015898776c2cmr33148936plb.80.1654674557031; Wed, 08 Jun 2022 00:49:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654674557; cv=none; d=google.com; s=arc-20160816; b=Ah1gL1eQUy5gInehQ18MW/C5lP4yKKCVg25qOIsVhU3ot+89aNmJlAFOl7ZQuqOOZ3 LaTa25dsgBeNZMZBX6zyy9Em7JNkb7WEUT5LHj18dYwNqfnMSzq8CrIRWOqPR4M/BRsF WRG2AoScQUY28dEueRnVrIcAq00mZJ3SWLiArHteP4pi8fVtc2O1diGrFcZnxdt9DIWP c3azIsSXtUMSzLod9c/N8oWd6PAW4OgdAYC58Gz8DxIciUx1V2kIvy5iFui5JMl5W896 16oIsjFgYpYXBnbL3oKIyeLoc5eb7iej7ZWpPmXm1YEnwCAtRIv93EzNVF+f2eFzqHzE x2Fw== 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=db25qLXB9O3fFTHtUQD4ALkOuWbZK8BJ3wn7qOll96w=; b=XG7M/OWB7Ut2dxteiAwoM3UzLfLbbcPNr6JH1mPHndxG3RkqIDZNrnLAPjBPavYUxI K+KXJ79NDI8OSvs6n+yka5kYHvCdSm707llGNuTtJEgU4sqImymDSgO0W7ubmjNG8IPI H7BLX+hNQ9fgo2eD1vE1DW/W0AU57t6LKr6UCrrktpcNXKmvWPWyZYrLepgFhBlzpxNT 2Yw1iafjODXPbAX2zDXxHnnS4u20EiJeVF5AfjN3LAVChKowaXMiayD08WnIcwH0cX6v gSiR9ZCf31hI0alVvxf9CSEltmIrog1FcEPT0yTECSIFIqXYKjla0jQbB+hVJVPsS9dY duog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1yBv729P; 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 v37-20020a631525000000b003f9f41da8c6si27737368pgl.2.2022.06.08.00.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 00:49:17 -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=1yBv729P; 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 DDE31132A29; Wed, 8 Jun 2022 00:19:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346135AbiFGRWj (ORCPT + 99 others); Tue, 7 Jun 2022 13:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345982AbiFGRUI (ORCPT ); Tue, 7 Jun 2022 13:20:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BF3A106A71; Tue, 7 Jun 2022 10:20:01 -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 A5006617C0; Tue, 7 Jun 2022 17:20:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B79F6C385A5; Tue, 7 Jun 2022 17:19:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622400; bh=YRtEwHD08cb4Y7oVvPxN160oBBescAXbtKKzdrhTbSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1yBv729PwHJiraxYAByBkhaDP6f0TWKpEcLVvgQNb58Q4PadS7NA7aV5hG93qn9g8 IR3bUP2XChtu0g6fzO65BOfDwOwnvXsbwwdi+3+NNqz/+7/N3YyDxTovFZYW8Pg3Cf nmU1a+PV7+qSgnYjXaCUcFbdD/VDDchrpnd8QsOE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheyu Ma , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.10 045/452] media: pci: cx23885: Fix the error handling in cx23885_initdev() Date: Tue, 7 Jun 2022 18:58:22 +0200 Message-Id: <20220607164909.890523999@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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: Zheyu Ma [ Upstream commit e8123311cf06d7dae71e8c5fe78e0510d20cd30b ] When the driver fails to call the dma_set_mask(), the driver will get the following splat: [ 55.853884] BUG: KASAN: use-after-free in __process_removed_driver+0x3c/0x240 [ 55.854486] Read of size 8 at addr ffff88810de60408 by task modprobe/590 [ 55.856822] Call Trace: [ 55.860327] __process_removed_driver+0x3c/0x240 [ 55.861347] bus_for_each_dev+0x102/0x160 [ 55.861681] i2c_del_driver+0x2f/0x50 This is because the driver has initialized the i2c related resources in cx23885_dev_setup() but not released them in error handling, fix this bug by modifying the error path that jumps after failing to call the dma_set_mask(). Signed-off-by: Zheyu Ma Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/pci/cx23885/cx23885-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c index 4e8132d4b2df..a23c025595a0 100644 --- a/drivers/media/pci/cx23885/cx23885-core.c +++ b/drivers/media/pci/cx23885/cx23885-core.c @@ -2154,7 +2154,7 @@ static int cx23885_initdev(struct pci_dev *pci_dev, err = pci_set_dma_mask(pci_dev, 0xffffffff); if (err) { pr_err("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name); - goto fail_ctrl; + goto fail_dma_set_mask; } err = request_irq(pci_dev->irq, cx23885_irq, @@ -2162,7 +2162,7 @@ static int cx23885_initdev(struct pci_dev *pci_dev, if (err < 0) { pr_err("%s: can't get IRQ %d\n", dev->name, pci_dev->irq); - goto fail_irq; + goto fail_dma_set_mask; } switch (dev->board) { @@ -2184,7 +2184,7 @@ static int cx23885_initdev(struct pci_dev *pci_dev, return 0; -fail_irq: +fail_dma_set_mask: cx23885_dev_unregister(dev); fail_ctrl: v4l2_ctrl_handler_free(hdl); -- 2.35.1