Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp484413imn; Wed, 27 Jul 2022 11:29:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tZz1cwgdOVsOnCZ3RynG5zyc7/L3KIzAHae6JM7gpF2dK/HTXhue5Ul4Pe10MLf8oD3nyz X-Received: by 2002:a05:6402:524d:b0:43c:a8:70 with SMTP id t13-20020a056402524d00b0043c00a80070mr16810383edd.33.1658946576302; Wed, 27 Jul 2022 11:29:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946576; cv=none; d=google.com; s=arc-20160816; b=F0iYTQP0KuvQO6bvANDFOK8sf6qxVzmh62zWDTIlZ0WAS3OI67U+h0vk58kuxOxSDd ixIc/IuWznXy1Lt5qweOoyCaayLwaBqrJvrCb8saUv64avaf2kCyQlJqYSE3lZ24zLDs szSyUn181CBLv+48IdFwiATjTIw5Dly32bmmilkqE+wBrzqJBIkBlSy2uaUb2iajDUlg cVmUbZBJzWYPw/2YSN3GcHnINBsGqRDAywhfS3nVpcphNG3WXLpD/yZ2ImMNTOjIDwzh Q7kU0Nk6tGXBEFjwEEQx7TI8zBVSO17k/el1gicbUOWmJt6Oxr7Q9iTUOy+yrdO64VMI IAuw== 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=9jop2zaUookG7+Mt5tPJOkiVusdS+pTO53gKYM2o+x0=; b=cslgp2IA60Oia0/gHH1znNdtPjrz1hiZC0XumQV/2knxKaKEnuDcE14x7hemxelAWx zU2ms3NVmWlFOUFYXct/HrlGRuV+sNMxSCHjUPT1P2/l5e6VpNp1qgMEpAhj2qTrBVi8 zPZFeJQV5hGo81PcPLUuQA61OEXW2yIErm5hrYpnQ9svHJWsaBIfB1tse/T1oP3JTW1z RjoDL/Det2riKePHFZoD1WvyloST0bPcE26xj/2RFEAEBEu3nhJuPvot9o1elZTl54YX XMR/To8nXLqniL/sReMrWpF3HKArF+2AB6Wvj+QDKiGbhyPM2s7SShvJQOqJV80Ufxhh Oonw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AOapQWjY; 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 qb27-20020a1709077e9b00b0072f9b440ffbsi20407358ejc.225.2022.07.27.11.29.10; Wed, 27 Jul 2022 11:29:36 -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=AOapQWjY; 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 S235611AbiG0QW6 (ORCPT + 99 others); Wed, 27 Jul 2022 12:22:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235089AbiG0QWY (ORCPT ); Wed, 27 Jul 2022 12:22:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8DE14BD3F; Wed, 27 Jul 2022 09:22:22 -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 797E1B821B9; Wed, 27 Jul 2022 16:22:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6CE4C433D6; Wed, 27 Jul 2022 16:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658938940; bh=wqVnnehyqL07Uxo1ruuI3rShLmuNDpQvGUe5zZS3fY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AOapQWjYtgjxw/AY5WqBIYDNI/RNdSpxLCsuDNfd3dqfkLM2GBuhWYcvLcjZ8gLud r2ZZRdZsmo5KxWERoWZx3VWlMfQE/wxigtlk63f5HyxZPIGvVyb+1asV3iv7kPqfFX 4Jk++lLqObMmXG4sPei/eqdJgRvZpErLkLMrnWDY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuah Khan , stable , Sasha Levin Subject: [PATCH 4.9 04/26] misc: rtsx_usb: use separate command and response buffers Date: Wed, 27 Jul 2022 18:10:33 +0200 Message-Id: <20220727160959.317226011@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727160959.122591422@linuxfoundation.org> References: <20220727160959.122591422@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 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 [ Upstream commit 3776c78559853fd151be7c41e369fd076fb679d5 ] 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 Signed-off-by: Sasha Levin --- drivers/mfd/rtsx_usb.c | 26 +++++++++++++++++--------- include/linux/mfd/rtsx_usb.h | 1 - 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/mfd/rtsx_usb.c b/drivers/mfd/rtsx_usb.c index b0ebd2299599..134c6fbd9c50 100644 --- a/drivers/mfd/rtsx_usb.c +++ b/drivers/mfd/rtsx_usb.c @@ -642,15 +642,18 @@ static int rtsx_usb_probe(struct usb_interface *intf, 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_interface *intf, 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 usb_interface *intf) 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 diff --git a/include/linux/mfd/rtsx_usb.h b/include/linux/mfd/rtsx_usb.h index d3d231afb17c..09b08ff08830 100644 --- a/include/linux/mfd/rtsx_usb.h +++ b/include/linux/mfd/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; -- 2.35.1