Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3178219imw; Mon, 11 Jul 2022 03:39:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v1hZjCXkE8vRGy6YJh7sln+LxEA7Rp07oHLcUvpOtG4eKUySm+N8i8PetMXninHbX5bgHf X-Received: by 2002:a17:906:8459:b0:72b:60c8:107d with SMTP id e25-20020a170906845900b0072b60c8107dmr2275787ejy.142.1657535945563; Mon, 11 Jul 2022 03:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657535945; cv=none; d=google.com; s=arc-20160816; b=ruLHXZFtXBwS2nduA+1GL3oi1K9le3AuyZFc747dh8jyOYmlOmIPjhi+HqF5Qczkay hxgcrjBIJp7YGAHrWn635OR5Y5rz6Q489R0d8amach7+vZ2/tnJguaGOSx92yxa3d0Q1 LfmAHVywY4Zj+UcYjkomPMu/5Q8FZ6tJ5w842way1muRP6FBFRzLx9RtbXwYGapxN71H N9ppzf7mGSMXhZc09ddflePQqpLZCxFIHcHRCFaETOIbgX7bEU4jkUKph0eYWCSLQ2Wd nK6Bj7t/G2fTAQvT6Ham7WeHlCCp/ROe65W+bbYFSGk1s4ygwFmL6RvsCbTOP/EuM3Gs ivmQ== 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=uRDCgYn9MLfDnbuHlvK5vgGy01RfRRQvpKTFvn1GCQI=; b=hKzLM0WJyIHTOCJNFCpvvu02ID27brLO6ClqWutwukIoG+wIyeX1JrjB3eUvbz1d0l Bn7KctmV/jaDeOgiY+4o3rE8H8uPz6oTDjC/N9p4qIDaNOGmLMwTwaHt3AM1BZlnsog1 j4MPOuPSCcSCm+DViu5qwwFcMOr1FdLSaDq6/vf0s7JZHeWqGO2l6nmYnwKuXr1q8LQl wallM6VVZ3A4XbAU1F2DN+G4ubxYH+Oii2WKs7f7knbkRpmRo7xwXkPptYE0lEcOUeb3 hydYTWEllzMyR7vml5FGsqw/1LBWIQUjQGYVUNkIv/FkYm5Ym6G6lTNzlahkYBQiH+IK UT3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EsEm9Egi; 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 z10-20020a05640235ca00b0043a992a782dsi11914276edc.450.2022.07.11.03.38.41; Mon, 11 Jul 2022 03:39:05 -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=EsEm9Egi; 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 S231266AbiGKJXd (ORCPT + 99 others); Mon, 11 Jul 2022 05:23:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231904AbiGKJW5 (ORCPT ); Mon, 11 Jul 2022 05:22:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6C261E0; Mon, 11 Jul 2022 02:13:37 -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 2D912B80CEF; Mon, 11 Jul 2022 09:13:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97F43C34115; Mon, 11 Jul 2022 09:13:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657530815; bh=6P8CXs3MGbhhmsH5Oe+Hzg9axBWkQxRbYazFIsEe6KE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EsEm9EgiM7OecTUMv2owli2ovtet6Anv02vhFPefs7/gmGRNmBpscrp3tBZJmzedC 3LJ9BFnGboVndEoqbomcTJ1NK7sc/jDDinm90BFpn1y/5bqnY+7RXUP9MCOUDEXj5R Xr9I5n3pcFM2EZqxBeuwQG+2p8pN60XNzM5HETL4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuah Khan , stable Subject: [PATCH 5.10 48/55] misc: rtsx_usb: use separate command and response buffers Date: Mon, 11 Jul 2022 11:07:36 +0200 Message-Id: <20220711090543.172166945@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090541.764895984@linuxfoundation.org> References: <20220711090541.764895984@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.7 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: Shuah Khan commit 3776c78559853fd151be7c41e369fd076fb679d5 upstream. rtsx_usb uses same buffer for command and response. There could be a potential conflict using the same buffer for both especially if retries and timeouts are involved. Use separate command and response buffers to avoid conflicts. Signed-off-by: Shuah Khan Cc: stable Link: https://lore.kernel.org/r/07e3721804ff07aaab9ef5b39a5691d0718b9ade.1656642167.git.skhan@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/misc/cardreader/rtsx_usb.c | 26 +++++++++++++++++--------- include/linux/rtsx_usb.h | 1 - 2 files changed, 17 insertions(+), 10 deletions(-) --- a/drivers/misc/cardreader/rtsx_usb.c +++ b/drivers/misc/cardreader/rtsx_usb.c @@ -631,15 +631,18 @@ static int rtsx_usb_probe(struct usb_int ucr->pusb_dev = usb_dev; - ucr->iobuf = kmalloc(IOBUF_SIZE, GFP_KERNEL); - if (!ucr->iobuf) + ucr->cmd_buf = kmalloc(IOBUF_SIZE, GFP_KERNEL); + if (!ucr->cmd_buf) return -ENOMEM; + ucr->rsp_buf = kmalloc(IOBUF_SIZE, GFP_KERNEL); + if (!ucr->rsp_buf) + goto out_free_cmd_buf; + usb_set_intfdata(intf, ucr); ucr->vendor_id = id->idVendor; ucr->product_id = id->idProduct; - ucr->cmd_buf = ucr->rsp_buf = ucr->iobuf; mutex_init(&ucr->dev_mutex); @@ -667,9 +670,11 @@ static int rtsx_usb_probe(struct usb_int out_init_fail: usb_set_intfdata(ucr->pusb_intf, NULL); - kfree(ucr->iobuf); - ucr->iobuf = NULL; - ucr->cmd_buf = ucr->rsp_buf = NULL; + kfree(ucr->rsp_buf); + ucr->rsp_buf = NULL; +out_free_cmd_buf: + kfree(ucr->cmd_buf); + ucr->cmd_buf = NULL; return ret; } @@ -682,9 +687,12 @@ static void rtsx_usb_disconnect(struct u mfd_remove_devices(&intf->dev); usb_set_intfdata(ucr->pusb_intf, NULL); - kfree(ucr->iobuf); - ucr->iobuf = NULL; - ucr->cmd_buf = ucr->rsp_buf = NULL; + + kfree(ucr->cmd_buf); + ucr->cmd_buf = NULL; + + kfree(ucr->rsp_buf); + ucr->rsp_buf = NULL; } #ifdef CONFIG_PM --- a/include/linux/rtsx_usb.h +++ b/include/linux/rtsx_usb.h @@ -54,7 +54,6 @@ struct rtsx_ucr { struct usb_device *pusb_dev; struct usb_interface *pusb_intf; struct usb_sg_request current_sg; - unsigned char *iobuf; struct timer_list sg_timer; struct mutex dev_mutex;