Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3161885imw; Mon, 11 Jul 2022 03:14:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t5fs4XRdW2IHLJ1DO9k6Ly/8xEusAd+1T6Bmh58ZMGRxJG5snpM5pL+nGiTDKfTgGv7RhK X-Received: by 2002:a17:907:6ea7:b0:726:41de:78ac with SMTP id sh39-20020a1709076ea700b0072641de78acmr18155923ejc.452.1657534496190; Mon, 11 Jul 2022 03:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657534496; cv=none; d=google.com; s=arc-20160816; b=rT8tBdcyYYnxjY1QZekePOTflkmMvssMA1h359o1IQjC628XZMWv0WrnTepmvBzABN 6V7GVfCdzYcCzSBfDx0wrfl40HDcpjJydhIilrkpKjvbpR1iIplq2QE8GAUCkduceQfw /2RfpfqLLFeAG3Dk+0TMxHugL4blVHjIeg1tJ59x4bwa/2x57h+cGz4urs4crIXcC+Rz Thubaj/FT/frEB8Ysgq2tdl/BFe/TVPbrq8qiYz1KJVOR41N+svkeLP36M2pDx0FLwY3 FPEe+4Gs5mdJhdHgbeXQTanbXmPrQ9AQRU1eyf/s2xwWiniiiB1fJX/41rYYTfhnjohK XpRw== 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=0eOjj7A5KxCxdjE+MSHvwL2rR7kLeDkznZDQOTq7H/I=; b=0oH/D14tsUqdloNkXY38QIA1u28VJ9tninWDuoyXOWGRm7xR3EI1OTDeSZ106/0cK3 53Lnse6bcnWrSrwctFWdqsDOL2J8j8HpuQmUg5YqvqNecB7iP1/9S1wSlA0+P4tYrkd1 LCDvjTHkKxlb0OQgCUfO23sf7Kh3zKpB++bX9BzrIU8CgzRHJKlTw8fxnIhrBPMNmWaD 6jbYYKTZg/XhtMxum3ERtvFGVM5QR4kASu+R5V3IU6JmX9D1fNiHYbYQn/q3rJnRKFkm 2j0nOrQb0HPYJZk9UGvGpDucZNHmYPowP7R/Pu3GrgwBzCzMvt8kQ9aYjQRIy1Jp+knv m65g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aEGYLpyN; 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 w11-20020a056402268b00b0043ad6a701f0si3750443edd.398.2022.07.11.03.14.31; Mon, 11 Jul 2022 03:14: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=aEGYLpyN; 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 S231403AbiGKJMd (ORCPT + 99 others); Mon, 11 Jul 2022 05:12:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231328AbiGKJLj (ORCPT ); Mon, 11 Jul 2022 05:11:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8348237CF; Mon, 11 Jul 2022 02:09:10 -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 7CCCC61148; Mon, 11 Jul 2022 09:09:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89AEFC34115; Mon, 11 Jul 2022 09:09:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657530549; bh=3yFvYkvFhSA5opWMSNYj1tkEXOgzdE7ISodinZieUPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aEGYLpyN9Cq5XFrS2EznHJ8lM7qLX5NPaYZXWKzTSjcHLqbEwyoIxF/qdcvBCe8VJ dogWzL6F4murkZde5hhlFITRozUEbs85V8WeAiKDPWqI93jibPhB6XNhUr7oPZvX9k xYDHkfmDDWiP6Iz3NICTqGkB5BTorKcsqUwhSSFo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuah Khan , stable Subject: [PATCH 4.19 25/31] misc: rtsx_usb: use separate command and response buffers Date: Mon, 11 Jul 2022 11:07:04 +0200 Message-Id: <20220711090538.589749386@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090537.841305347@linuxfoundation.org> References: <20220711090537.841305347@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 @@ -642,15 +642,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); @@ -678,9 +681,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; } @@ -693,9 +698,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 @@ -65,7 +65,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;