Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2910497yba; Mon, 22 Apr 2019 15:31:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/x8Igo/KAIi6rQTOC88M77Hnq4HfNNRLvXYjUA6Z7PrHLR2eAQo+aTlONCr3iZTmI4OIA X-Received: by 2002:a63:ac12:: with SMTP id v18mr21477912pge.111.1555972298902; Mon, 22 Apr 2019 15:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555972298; cv=none; d=google.com; s=arc-20160816; b=j+Ox9l3xpIZFYUE6GrYj5dEQFfUwOH3DEvUzYJCWZYwY9QNIaTOaiLpdXjC4+aOiPd h7b10dXjJmMt1sCTF8XfetteKzoQtoNAzy7Bj6uzRj56u76CW9oCoxY7iyssqjPnDje+ DhAKKTrNFXOuz13heCisGQec8R7EBb1cmwAJMnVOORvxw5C/FS5OeCf4po7aIK1rDoyk WrgLygT/tTITNVNE8h4dGW4shpWgsrvAYbgnZQEuVcom1NvzbpSidQAWpoHSmSy6fshQ WyfoO8eyUzCG1sl1Gr4VnS6zrhCEF3xRhbPcRln7ba/JSw73NVRcR6ResXh8c+y3oVUU mBjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LAd0tm53XHNmDnlFg58BjxZ6tyDzMVBHdS5Bgq+zk4I=; b=n9ETC6pYNjhyUKZdNqOigd1Cc4rGd0ugvhAc3qZG3AzZtzRePzKnoG1TM1KdVhBrDF wizCZUYoXMOD8gufjgKuUc5vdtklOnyL5bmdDtX6GoHThfOauA50iiTu7HmjRyacgl/y JkEKiG9TowZNIPLvLKGeI3Sf/+N4u5D5GRR1GCweYVhcajuB8XNOxGwOvPvvoRvODpjR /xpXMyL2nLmGGZLk/aRWgXwFS369KKKpDA28jVpe8unnwwavChXHqcXN/1WYggMJm/Gf okGwwA7MUbZFLzOI8bPFsyPaAIU/gUF1M42phcpBznTqHZnioP+M4WKHjuekU8cb9GJd ujMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HvI5ULe+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si12851234pgq.116.2019.04.22.15.31.23; Mon, 22 Apr 2019 15:31:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HvI5ULe+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729998AbfDVTqi (ORCPT + 99 others); Mon, 22 Apr 2019 15:46:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:48822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729578AbfDVTqe (ORCPT ); Mon, 22 Apr 2019 15:46:34 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 040E8218B0; Mon, 22 Apr 2019 19:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962393; bh=g5iThoKCvxBizMvbDxJKljny9/OeEm0wTEKPRcs8Aeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HvI5ULe+QtaPZIdHf8loOIFi4HxBlA6xcYnvD2vmop6jFCGMSYw5ZPnu74qDLByNq sHrvjIO12jBsn71JKMrJYyieouVFMBPS4XFFf84sCjSw694Em2hY18Obdcz6JmglcX TJ6q7CsM0xXkkl0FiNRI8Bjc07cHjL865KEbdtXE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Carpenter , Greg Kroah-Hartman , Sasha Levin , devel@driverdev.osuosl.org Subject: [PATCH AUTOSEL 4.19 33/68] staging: rtl8712: uninitialized memory in read_bbreg_hdl() Date: Mon, 22 Apr 2019 15:44:41 -0400 Message-Id: <20190422194516.11634-33-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194516.11634-1-sashal@kernel.org> References: <20190422194516.11634-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 22c971db7dd4b0ad8dd88e99c407f7a1f4231a2e ] Colin King reported a bug in read_bbreg_hdl(): memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz); The problem is that "val" is uninitialized. This code is obviously not useful, but so far as I can tell "pcmd->cmdcode" is never GEN_CMD_CODE(_Read_BBREG) so it's not harmful either. For now the easiest fix is to just call r8712_free_cmd_obj() and return. Fixes: 2865d42c78a9 ("staging: r8712u: Add the new driver to the mainline kernel") Reported-by: Colin Ian King Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin (Microsoft) --- drivers/staging/rtl8712/rtl8712_cmd.c | 10 +--------- drivers/staging/rtl8712/rtl8712_cmd.h | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c b/drivers/staging/rtl8712/rtl8712_cmd.c index b1dfe9f46619..63bc811681d9 100644 --- a/drivers/staging/rtl8712/rtl8712_cmd.c +++ b/drivers/staging/rtl8712/rtl8712_cmd.c @@ -159,17 +159,9 @@ static u8 write_macreg_hdl(struct _adapter *padapter, u8 *pbuf) static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf) { - u32 val; - void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd); struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; - if (pcmd->rsp && pcmd->rspsz > 0) - memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz); - pcmd_callback = cmd_callback[pcmd->cmdcode].callback; - if (!pcmd_callback) - r8712_free_cmd_obj(pcmd); - else - pcmd_callback(padapter, pcmd); + r8712_free_cmd_obj(pcmd); return H2C_SUCCESS; } diff --git a/drivers/staging/rtl8712/rtl8712_cmd.h b/drivers/staging/rtl8712/rtl8712_cmd.h index 9181bb6b04c3..a101a0a50955 100644 --- a/drivers/staging/rtl8712/rtl8712_cmd.h +++ b/drivers/staging/rtl8712/rtl8712_cmd.h @@ -152,7 +152,7 @@ enum rtl8712_h2c_cmd { static struct _cmd_callback cmd_callback[] = { {GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/ {GEN_CMD_CODE(_Write_MACREG), NULL}, - {GEN_CMD_CODE(_Read_BBREG), &r8712_getbbrfreg_cmdrsp_callback}, + {GEN_CMD_CODE(_Read_BBREG), NULL}, {GEN_CMD_CODE(_Write_BBREG), NULL}, {GEN_CMD_CODE(_Read_RFREG), &r8712_getbbrfreg_cmdrsp_callback}, {GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/ -- 2.19.1