Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4372211rwb; Tue, 6 Sep 2022 06:42:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR4hAvmXlXq6+y8YMeSuDK4lqtfFovFhx8q3k3lK4Xhl+fvDkgrw+zdOhKsCuK8AV0Z5a2JD X-Received: by 2002:a05:6402:1b0c:b0:44e:8ae1:8016 with SMTP id by12-20020a0564021b0c00b0044e8ae18016mr7986158edb.342.1662471776109; Tue, 06 Sep 2022 06:42:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662471776; cv=none; d=google.com; s=arc-20160816; b=lKPC9Jj44MDPWIDDsfeqhTNU8poJYdr4KFUx1n1qtB+SeXBV+9ItbAvz+zDwSH/EQK RW5Hyb9Taw1fDiB6rhZittEeC14RhPzIrFAq4aE4rqCcZaecdN03MU7GaEWD59ChJ0Ik d3+e/FJf679ohTbeJL/1wQAfQZaAPgtwqJw3PPPaXK1EiyP+rw7SxDNM1oH+5JRGs3lw EB6SZrUsCe4IP4VVImej/xGTOwPao/kn0HnzlpxRFc41vChSxZ5zMmtcqrMe2kqRg68P 6wFmhxrc4jQNc//HR/TX7E7qEsWgf58QOXeaPB7BLfdC1wfe2PSwLkWywpVf9hjHk+zV 8bcA== 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=1k9GKoUQlUASaXKJ2bONsbqiBm8JDKlzxxps7y2WLiI=; b=yDxFhwh2CDNJiORiD1uQC5XFqMesPdSN7GrWSykLOaD5Sohf3qX5iHUsfkpO0NlQLp czvRmYp+Fd6Z2f8xX38WffGigvcoZmaFhKmoxd/feIBoSP0yBdo+p1DYMgDjdVhg9ZtQ wSfLZJbcc1hUu4dv2D0aeviO5rG1SFyP508bjXqRtgf2TdPvTJ9M94ta4rvfAU17ntfU N9Xx4IGSxxvH33qeMRiMX6DCDludCTBfmoGid/zz5TysNUGeIS27NzKjXRFIj45Dar+8 i0/grJCG0Xn1HK47axZ1h097Essv0Dpx+h/WEYae66eRVfBddIAkx9d/P3OrOUctzmOm 2VCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UhtfaZZH; 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 p24-20020a056402501800b0044e78dbb615si5059098eda.379.2022.09.06.06.42.27; Tue, 06 Sep 2022 06:42:56 -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=UhtfaZZH; 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 S232690AbiIFNjt (ORCPT + 99 others); Tue, 6 Sep 2022 09:39:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240724AbiIFNht (ORCPT ); Tue, 6 Sep 2022 09:37:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0E681836D; Tue, 6 Sep 2022 06:34:39 -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 4042861547; Tue, 6 Sep 2022 13:34:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41564C433C1; Tue, 6 Sep 2022 13:34:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471274; bh=jCbiulv3+SkkRMqoeGCKxedOr2kOBhDnFPmxoCl8K/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UhtfaZZHzE3Gz80yIXZHMUWCFnY0m2ezx+KvO0o7qv5zZZq+hx4TZZJv2QRwSTTDb 5koKpnbXXtlLKDA9FvEvovfNasaaxTqphcMfLx81YL/bMpIP10n0Kl9lW5fbiFIAhC TWu8/HLfR6N0f9ZFR3BrOARQfXVRmaHnJvq+2aUw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Zheng Wang , Dan Carpenter Subject: [PATCH 5.10 22/80] staging: rtl8712: fix use after free bugs Date: Tue, 6 Sep 2022 15:30:19 +0200 Message-Id: <20220906132817.862604792@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132816.936069583@linuxfoundation.org> References: <20220906132816.936069583@linuxfoundation.org> User-Agent: quilt/0.67 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: Dan Carpenter commit e230a4455ac3e9b112f0367d1b8e255e141afae0 upstream. _Read/Write_MACREG callbacks are NULL so the read/write_macreg_hdl() functions don't do anything except free the "pcmd" pointer. It results in a use after free. Delete them. Fixes: 2865d42c78a9 ("staging: r8712u: Add the new driver to the mainline kernel") Cc: stable Reported-by: Zheng Wang Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/Yw4ASqkYcUhUfoY2@kili Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_cmd.c | 36 ---------------------------------- 1 file changed, 36 deletions(-) --- a/drivers/staging/rtl8712/rtl8712_cmd.c +++ b/drivers/staging/rtl8712/rtl8712_cmd.c @@ -117,34 +117,6 @@ static void r871x_internal_cmd_hdl(struc kfree(pdrvcmd->pbuf); } -static u8 read_macreg_hdl(struct _adapter *padapter, u8 *pbuf) -{ - void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd); - struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; - - /* invoke cmd->callback function */ - pcmd_callback = cmd_callback[pcmd->cmdcode].callback; - if (!pcmd_callback) - r8712_free_cmd_obj(pcmd); - else - pcmd_callback(padapter, pcmd); - return H2C_SUCCESS; -} - -static u8 write_macreg_hdl(struct _adapter *padapter, u8 *pbuf) -{ - void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd); - struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; - - /* invoke cmd->callback function */ - pcmd_callback = cmd_callback[pcmd->cmdcode].callback; - if (!pcmd_callback) - r8712_free_cmd_obj(pcmd); - else - pcmd_callback(padapter, pcmd); - return H2C_SUCCESS; -} - static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf) { struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; @@ -213,14 +185,6 @@ static struct cmd_obj *cmd_hdl_filter(st pcmd_r = NULL; switch (pcmd->cmdcode) { - case GEN_CMD_CODE(_Read_MACREG): - read_macreg_hdl(padapter, (u8 *)pcmd); - pcmd_r = pcmd; - break; - case GEN_CMD_CODE(_Write_MACREG): - write_macreg_hdl(padapter, (u8 *)pcmd); - pcmd_r = pcmd; - break; case GEN_CMD_CODE(_Read_BBREG): read_bbreg_hdl(padapter, (u8 *)pcmd); break;