From patchwork Wed Nov 28 14:39:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152290 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1170583ljp; Wed, 28 Nov 2018 06:40:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/VBpjYx0sBtWpNdrgdcEQrwLaiiPup63U3rLycQPZlkU7dh1zJADA5VHic68wWmW3Dfeo4H X-Received: by 2002:a17:902:34a:: with SMTP id 68mr29102247pld.268.1543416012554; Wed, 28 Nov 2018 06:40:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543416012; cv=none; d=google.com; s=arc-20160816; b=sjCar0d6Oety7v+OaYGGMoUVOLAYYC0TioqlQznvONN6VnThe+JL4bWnWOHGCRW3Nb zvuk8+T0LEstx6wL9Phy6fXiuGQW0yotPTmms+cZhXVxGYRpG9FGGHUKSQROofKs38Al Ed+lVEYXFSQa+VF3bXsritvc8M6oyLSJXoXtjARugN83eDK3NEyCqkQ7NBFSYJ48SsvJ dbmIhumIB/wJA9/JUzug7LIno8t1mBLdRt0yASrcJD0F0vqshJO2Aj7G3VqnLrJtHkAZ Mudz8+tDkz0Lu5LshWFjP8JQFoBBwRu9hH0yquaxMYyEfI5X2VP197Y7QtHxUVYQ0YjG EqdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=9+BO1vkaNAN3CiF20VlUdWRa39/+DjLfHZpZJY6bEfs=; b=v7mtZActe6jq2DbIrHbqlVYKgwUrqcBHhLoH60DMRIhbgcfLO/CDUQr0pgTamMLXU7 w07Z3COWAFndFFLegKK47rWK5yufTA5omWLX/fsIV/jMXq+1UORHhsgo9e9lCrVjHuz3 YRNvhkIv1DqUc7MOnLjtz0MCHtOes2a37X5kr0DagtTE/8UL+w5gojSICmbk+PwQ4WjZ sD0Uco3/9VRvMogJfH1ldxgJo3na8y/7IHcX8HkJTc7mDUTCzww5UUoyWFKxQihzlF8s jOeCH3HqZrObhr6E6+1j8i0VGQiiCE3GiQCe445OGkZAVtTqFMMdzV2tgg388Xhi+HJb mENg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fth6L0ZG; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i67si5274274pfc.148.2018.11.28.06.40.12; Wed, 28 Nov 2018 06:40:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=fth6L0ZG; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728251AbeK2BmE (ORCPT + 15 others); Wed, 28 Nov 2018 20:42:04 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:42208 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727941AbeK2BmE (ORCPT ); Wed, 28 Nov 2018 20:42:04 -0500 Received: by mail-pl1-f196.google.com with SMTP id x21-v6so17461125pln.9 for ; Wed, 28 Nov 2018 06:40:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9+BO1vkaNAN3CiF20VlUdWRa39/+DjLfHZpZJY6bEfs=; b=fth6L0ZGrwqhO0TlpjW792UCJltFFUaJaXDXCal+okLBMmDH8tXo+jmp9mrylHONSf iEzy1CKyI+JAEoliaCkxoJy3Vw/eKiVF0DW8SqcTStuiKwf5RsEulCG62JkH3gG+UnUy cKXgCS4u1A5PuaTWFWpzhgrZoMHY4vzTN23DQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9+BO1vkaNAN3CiF20VlUdWRa39/+DjLfHZpZJY6bEfs=; b=JOSt99lD5JLaCIzuIYSUGJrf+Xew1BvzBSElKh00OD3PNZaasTJbPKbNigYjzMx9Wz 5XXEa9thU8Z6zR18ra/qBvTmwBhReeqAETGkkmXDIdqmCR8N7bN5//X6bjofn72qwVwt z4PiBH5e+hx8Tu4eLkjuyh3clzSaxzV6qPq8K+evwDlBhvpwdmdWNnhIKWvMWjZGhlmD X5ZqaXMkOu2c9w2FcKoQ9ozmtw3zU4LIppnFtBQb09i6+q+V18AA7mZlb/Wy/xQr0Dc3 499rNqM/AGi+jXW4OtcqMlWvlZ0KRqQ8TYP95G9UXTvshnrVgXpGhCjvhjo1Ghh89P4l Jrjw== X-Gm-Message-State: AA+aEWZM/pQzHRB5ZeaCfN20pplbk0lBm8nfGI/m5DBa3h0q7x+MaVzJ +H+UL6E5MjyPffEotDFlA+3nqQ== X-Received: by 2002:a17:902:e18d:: with SMTP id cd13mr34358606plb.262.1543416010931; Wed, 28 Nov 2018 06:40:10 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id b26sm24227637pfe.91.2018.11.28.06.40.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:40:10 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Vasanthakumar Thiagarajan , Kalle Valo Subject: [PATCH for-4.9.y 01/10] ath10k: fix kernel panic due to race in accessing arvif list Date: Wed, 28 Nov 2018 20:09:55 +0530 Message-Id: <1543416004-1547-2-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> References: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vasanthakumar Thiagarajan commit ebaa4b1620bf69f2bc43cb45ea85fbafdaec23c3 upstream. arvifs list is traversed within data_lock spin_lock in tasklet context to fill channel information from the corresponding vif. This means any access to arvifs list for add/del operations should also be protected with the same spin_lock to avoid the race. Fix this by performing list add/del on arvfis within the data_lock. This could fix kernel panic something like the below. LR is at ath10k_htt_rx_pktlog_completion_handler+0x100/0xb6c [ath10k_core] PC is at ath10k_htt_rx_pktlog_completion_handler+0x1c0/0xb6c [ath10k_core] Internal error: Oops: 17 [#1] PREEMPT SMP ARM [] (ath10k_htt_rx_pktlog_completion_handler+0x2f4/0xb6c [ath10k_core]) [] (ath10k_htt_txrx_compl_task+0x8b4/0x1188 [ath10k_core]) [] (tasklet_action+0x8c/0xec) [] (__do_softirq+0xdc/0x208) [] (irq_exit+0x84/0xe0) [] (__handle_domain_irq+0x80/0xa0) [] (gic_handle_irq+0x38/0x5c) [] (__irq_svc+0x40/0x74) (gdb) list *(ath10k_htt_rx_pktlog_completion_handler+0x1c0) 0x136c0 is in ath10k_htt_rx_h_channel (drivers/net/wireless/ath/ath10k/htt_rx.c:769) 764 struct cfg80211_chan_def def; 765 766 lockdep_assert_held(&ar->data_lock); 767 768 list_for_each_entry(arvif, &ar->arvifs, list) { 769 if (arvif->vdev_id == vdev_id && 770 ath10k_mac_vif_chan(arvif->vif, &def) == 0) 771 return def.chan; 772 } 773 Signed-off-by: Vasanthakumar Thiagarajan Signed-off-by: Kalle Valo Signed-off-by: Amit Pundir --- drivers/net/wireless/ath/ath10k/mac.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.7.4 diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 5fe6841b8889..fb632a454fc2 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -4967,7 +4967,9 @@ static int ath10k_add_interface(struct ieee80211_hw *hw, } ar->free_vdev_map &= ~(1LL << arvif->vdev_id); + spin_lock_bh(&ar->data_lock); list_add(&arvif->list, &ar->arvifs); + spin_unlock_bh(&ar->data_lock); /* It makes no sense to have firmware do keepalives. mac80211 already * takes care of this with idle connection polling. @@ -5118,7 +5120,9 @@ static int ath10k_add_interface(struct ieee80211_hw *hw, err_vdev_delete: ath10k_wmi_vdev_delete(ar, arvif->vdev_id); ar->free_vdev_map |= 1LL << arvif->vdev_id; + spin_lock_bh(&ar->data_lock); list_del(&arvif->list); + spin_unlock_bh(&ar->data_lock); err: if (arvif->beacon_buf) { @@ -5164,7 +5168,9 @@ static void ath10k_remove_interface(struct ieee80211_hw *hw, arvif->vdev_id, ret); ar->free_vdev_map |= 1LL << arvif->vdev_id; + spin_lock_bh(&ar->data_lock); list_del(&arvif->list); + spin_unlock_bh(&ar->data_lock); if (arvif->vdev_type == WMI_VDEV_TYPE_AP || arvif->vdev_type == WMI_VDEV_TYPE_IBSS) { From patchwork Wed Nov 28 14:39:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152291 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1170644ljp; Wed, 28 Nov 2018 06:40:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/XVrqc4/NCrOCRPd+aWDBEb87MDlNHmpyiEWTe1gGl0knrCGl992gbpN0yhxuVInS2HuH7R X-Received: by 2002:a17:902:720c:: with SMTP id ba12mr20609631plb.79.1543416015539; Wed, 28 Nov 2018 06:40:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543416015; cv=none; d=google.com; s=arc-20160816; b=qEfx0Fo6trbmmSJMfYzybtzPDoUVl7mtIecMqMSDJs9uXBTsB8bk2DrxmCOtCoOyli AQcjUN/qKnlzvC69uNDgmEGAqcOVI5wfK7+/WgPHmlW35qR5FXRmuZ139VT0FVNTHKTV itlAYDrtUj7a7meNkuhkMkm8Zf0pq2eczarEHS0++F1y1MsW0XNclghaVVkmZ2DqWfdp yTJKpQnNgDPRzL84AoeW0anbWvuihoKFwXWDG+rEcfy87zcuQNUHzNIsUeLWMDePa0PD lCQ8etpXHGzoqNFABl3R7Mfym459KgxSn8vmrz/7ccbvRz2iODwM0Bp0OPSGoGknFkTu 7UnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=OGjSNWuO6l6Vxy8LWCp2CNqpjJkIapuX5+++9+NLUr8=; b=qwCeCtwvzQ1cbDSD1QDapjQB8m5R6EQSuVWix+al5NMe+SjMUz2QvG9juhw+UNgNGu vRIKQNfkhO/442kjdZ/TPnWCmXPFKZ1I86PslF6NgI/6q5xea0zgIbfithW+sKRhAK+x sYOttZnNeyb/LwXaB6HjPIQbIIFYrZ4rGl32xwXjzS7c07Dls3dJ784lzmKTeHJLrlLl 4byHUqbsolLXn0NlbDwH+FxTG9zhPQlUQPbjyieOe+3xKIKj2U1Iu81dKySKGYUNXEpt 9RSAzmCzpdFVozkBCWTegbgKXqG+/3DMG9bKpD4uOOTHj4d9LiDkGoIZOE20yWXwrKGF roug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eLyHcJAJ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i67si5274274pfc.148.2018.11.28.06.40.15; Wed, 28 Nov 2018 06:40:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=eLyHcJAJ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728372AbeK2BmH (ORCPT + 15 others); Wed, 28 Nov 2018 20:42:07 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41260 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728342AbeK2BmH (ORCPT ); Wed, 28 Nov 2018 20:42:07 -0500 Received: by mail-pl1-f194.google.com with SMTP id u6so17480856plm.8 for ; Wed, 28 Nov 2018 06:40:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OGjSNWuO6l6Vxy8LWCp2CNqpjJkIapuX5+++9+NLUr8=; b=eLyHcJAJJIVAA2AOQxUG+k+LQ8ftr5t8wl0Iwn/4hrNESJTY4IFPbiyJt5JhwWX4xg HD/LfQY+n7hn6bijvz4AnD5pR8nGnMI6Kt3rO5P9qYN3iwg0TIcnaGf7D2K8xPByjawY kZrOJu/LC47M19fTVOdSKA0RxcAgZzsLDQUJU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OGjSNWuO6l6Vxy8LWCp2CNqpjJkIapuX5+++9+NLUr8=; b=G2aW6oJn3Jdu6+ItwoOiIPpDiHRc9tz7VPMySVshBg/7YxfiYQj44brMYUdHISwHfi MdaaqLNzBcMWkFWzfnsykdYrGVnCr3gwKVfQcl4un5Qa6IW2A+t3Jx57wkHpiHsgy4Ek 5qNH+bMA/xVBfagROo6mT8XXJFw8JSM/ucR+Xz0s9O6U9uzmYMxIKJopSV6KCZUyCo/f Y4RTr3YLIUvHXw9zZkSjORtLWOz1pyGkiTLBYJDvYu7+EL19JFhzBVRr7Giw/B85kxmu HF7Jg15zQM0X3MG1335RK58Kn+/GiuzvZiA+WnLZ4mWMEHFaV5FbEmN+zUmDD9pZW9lK w0lQ== X-Gm-Message-State: AA+aEWb0gSAdTYiyhUWFTvpXaXlrSxe07BUDAVNsDAAefzeC0UKvpZbW FWOpYHqNRT9wnkHY7gAOWjW9uw== X-Received: by 2002:a17:902:5066:: with SMTP id f35mr33317644plh.78.1543416013594; Wed, 28 Nov 2018 06:40:13 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id b26sm24227637pfe.91.2018.11.28.06.40.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:40:12 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Johannes Thumshirn , Johannes Berg , Kalle Valo Subject: [PATCH for-4.9.y 02/10] cw1200: Don't leak memory if krealloc failes Date: Wed, 28 Nov 2018 20:09:56 +0530 Message-Id: <1543416004-1547-3-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> References: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Johannes Thumshirn commit 9afdd6128c39f42398041bb2e017d8df0dcebcd1 upstream. The call to krealloc() in wsm_buf_reserve() directly assigns the newly returned memory to buf->begin. This is all fine except when krealloc() failes we loose the ability to free the old memory pointed to by buf->begin. If we just create a temporary variable to assign memory to and assign the memory to it we can mitigate the memory leak. Signed-off-by: Johannes Thumshirn Cc: Johannes Berg Signed-off-by: Kalle Valo Signed-off-by: Amit Pundir --- drivers/net/wireless/st/cw1200/wsm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/net/wireless/st/cw1200/wsm.c b/drivers/net/wireless/st/cw1200/wsm.c index ed93bf3474ec..be4c22e0d902 100644 --- a/drivers/net/wireless/st/cw1200/wsm.c +++ b/drivers/net/wireless/st/cw1200/wsm.c @@ -1805,16 +1805,18 @@ static int wsm_buf_reserve(struct wsm_buf *buf, size_t extra_size) { size_t pos = buf->data - buf->begin; size_t size = pos + extra_size; + u8 *tmp; size = round_up(size, FWLOAD_BLOCK_SIZE); - buf->begin = krealloc(buf->begin, size, GFP_KERNEL | GFP_DMA); - if (buf->begin) { - buf->data = &buf->begin[pos]; - buf->end = &buf->begin[size]; - return 0; - } else { - buf->end = buf->data = buf->begin; + tmp = krealloc(buf->begin, size, GFP_KERNEL | GFP_DMA); + if (!tmp) { + wsm_buf_deinit(buf); return -ENOMEM; } + + buf->begin = tmp; + buf->data = &buf->begin[pos]; + buf->end = &buf->begin[size]; + return 0; } From patchwork Wed Nov 28 14:39:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152292 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1170690ljp; Wed, 28 Nov 2018 06:40:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/UmY6lTmRvPAp9Qdz8jC6dqniWc1dmO9L8ArHheobax1R0Y5HQI3Ddfv37snwvzgd/wlm5J X-Received: by 2002:a17:902:b7cc:: with SMTP id v12mr37429940plz.8.1543416017582; Wed, 28 Nov 2018 06:40:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543416017; cv=none; d=google.com; s=arc-20160816; b=bv71Wzo1M6yAd/vbwXmdxQWA7woTDACW2XeQdnt666mM8RnNa9fLGv2RXLaJVnW4Nv ca3DSOn/YkC1ZwGhWiiviJs4z6gWg5zzBaO7YYYxw0rlaG2e8UQhtDpW8zdhBkFi2ilu aOKcztuUKX81IsX6A7vRAuBWgxjQrJOmluAcl6mNY/WsNLntzG7th0jjcnYo6+2wbPh4 Sl8x/MzDuIOpLfCwv4qOzTA9D1zEeQG9kvONjFEefp4CUBQpFafrpOfIib6FjTGV3Ufd c01/4x+BRXeUq0ZkmBo1orCGcvFwbg8In/squR5lKvxyNv9BtXlbHtWZT1iIinC42AW2 32wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=qDTuvO/AYLBV0mjjzuvfwJbIhTDCFQL+TCgTy1oHo9E=; b=i8pJEMGDu7+isW5aHTvZGdUy3P9G1lLuaiVXST+Uwgm/1VmksdkFbPu090lfi+IUcA q7NJ6YV/GqX/yWgT7/ZoOlxmUOt6vpmIPgw4A6o+L5mvMbZdWPKn7fS/BObSOXAG4AfY 3BBudpOnzbhoBHnPDUHBLdsO79UbCL8FGPkThKfTadc6B+OuI01koeUz1x381X/FltWA oOBd3uedVOkXG3VVmzYaCPdd56EG8abwxSKOE3IemJcU/b5fXb5E5bbBPMi5C/FK3DjU f+HLfPzIydknrEK6FGYwjMibnhK4hHJhzec2s1BwCst7JAAaL1/VXwzjoYMy+zGHrBPf S1ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PrHEQwJT; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i67si5274274pfc.148.2018.11.28.06.40.17; Wed, 28 Nov 2018 06:40:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=PrHEQwJT; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728342AbeK2BmJ (ORCPT + 15 others); Wed, 28 Nov 2018 20:42:09 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:34879 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728223AbeK2BmJ (ORCPT ); Wed, 28 Nov 2018 20:42:09 -0500 Received: by mail-pl1-f193.google.com with SMTP id p8so7190616plo.2 for ; Wed, 28 Nov 2018 06:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qDTuvO/AYLBV0mjjzuvfwJbIhTDCFQL+TCgTy1oHo9E=; b=PrHEQwJT6NuAVAgtZstFcLD69wT9GpiQy5kHGe5q+ZNwS6PUhvmLCP9N5YgL8Z+BbK zXG/p/xwONnB2dyfoxEADS/Q579Qnw0/5HoY94QOvjLIoVEBbTZPKtSKduwIIqpSaXtE AXv6+JyHUsou+DHCFNmUyuHppz3MzOv5a9jDg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qDTuvO/AYLBV0mjjzuvfwJbIhTDCFQL+TCgTy1oHo9E=; b=PQQC1I7J6lOggQsbLsFJNSADhVQyoivY3mOlXGDIdRzS1hbfhqWWQlAm5BNzuSIv2x AK0eaeaSOJHjEmrunv6b0jtcdr5c29avsG45CJvBthqC9YS9rmK+qACtMffGWPOQYfWv k/24XqMYkBzJIWYUJMIA7gIfW9NMSEG4HUzKHHAdcO6YGRG1gdqvE92sLKj941DcUIa4 Xur118eUUMtVlzJhd5eCe4GrBM+oRjfj5ThnKtqTJGdNXiGR1lvqpTVaGLEKghpGXeoO ruOjnAdrz8QbGkPq6/9cucn8kBSJwjEV18sUtdK/u61F+T7h1qVxspXG0TZjglcz/jra +/GA== X-Gm-Message-State: AA+aEWaoJnvwUOOtDGpnYCQuAklO8T/ho/0yJfbYqpv7Nx3HapDH672r rR6S8I6c65uOAtbkJVHk1TcJng== X-Received: by 2002:a17:902:b903:: with SMTP id bf3mr36486842plb.289.1543416016075; Wed, 28 Nov 2018 06:40:16 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id b26sm24227637pfe.91.2018.11.28.06.40.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:40:15 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Amitkumar Karwar , Kalle Valo Subject: [PATCH for-4.9.y 03/10] mwifiex: prevent register accesses after host is sleeping Date: Wed, 28 Nov 2018 20:09:57 +0530 Message-Id: <1543416004-1547-4-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> References: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Amitkumar Karwar commit ec815dd2a5f110f627d7955e0027a3a008f68166 upstream. Following is mwifiex driver-firmware host sleep handshake. It involves three threads. suspend handler, interrupt handler, interrupt processing in main work queue. 1) Enter suspend handler 2) Download HS_CFG command 3) Response from firmware for HS_CFG 4) Suspend thread waits until handshake completes(i.e hs_activate becomes true) 5) SLEEP from firmware 6) SLEEP confirm downloaded to firmware. 7) SLEEP confirm response from firmware 8) Driver processes SLEEP confirm response and set hs_activate to wake up suspend thread 9) Exit suspend handler 10) Read sleep cookie in loop and wait until it indicates firmware is sleep. 11) After processing SLEEP confirm response, we are at the end of interrupt processing routine. Recheck if there are interrupts received while we were processing them. During suspend-resume stress test, it's been observed that we may end up acessing PCIe hardware(in 10 and 11) when PCIe bus is closed which leads to a kernel crash. This patch solves the problem with below changes. a) action 10 above can be done before 8 b) Skip 11 if hs_activated is true. SLEEP confirm response is the last interrupt from firmware. No need to recheck for pending interrupts. c) Add flush_workqueue() in suspend handler. Signed-off-by: Amitkumar Karwar Reviewed-by: Brian Norris Tested-by: Brian Norris Signed-off-by: Kalle Valo Signed-off-by: Amit Pundir --- drivers/net/wireless/marvell/mwifiex/pcie.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index 1fdb86cd4734..8b70c909ecbb 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -118,6 +118,7 @@ static int mwifiex_pcie_suspend(struct device *dev) adapter = card->adapter; hs_actived = mwifiex_enable_hs(adapter); + flush_workqueue(adapter->workqueue); /* Indicate device suspended */ adapter->is_suspended = true; @@ -1676,9 +1677,6 @@ static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) if (!adapter->curr_cmd) { if (adapter->ps_state == PS_STATE_SLEEP_CFM) { - mwifiex_process_sleep_confirm_resp(adapter, skb->data, - skb->len); - mwifiex_pcie_enable_host_int(adapter); if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, CPU_INTR_SLEEP_CFM_DONE)) { @@ -1691,6 +1689,9 @@ static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) while (reg->sleep_cookie && (count++ < 10) && mwifiex_pcie_ok_to_access_hw(adapter)) usleep_range(50, 60); + mwifiex_pcie_enable_host_int(adapter); + mwifiex_process_sleep_confirm_resp(adapter, skb->data, + skb->len); } else { mwifiex_dbg(adapter, ERROR, "There is no command but got cmdrsp\n"); @@ -2329,6 +2330,8 @@ static int mwifiex_process_pcie_int(struct mwifiex_adapter *adapter) ret = mwifiex_pcie_process_cmd_complete(adapter); if (ret) return ret; + if (adapter->hs_activated) + return ret; } if (card->msi_enable) { From patchwork Wed Nov 28 14:39:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152293 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1170749ljp; Wed, 28 Nov 2018 06:40:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/X4iFcZuyJjDD+MYVLADwYFMwBMJvP0saWHyv4Z5GKeC0AVfJHrYLlus9ApobdxgI1SDqmw X-Received: by 2002:a17:902:6a8b:: with SMTP id n11-v6mr37774667plk.311.1543416020749; Wed, 28 Nov 2018 06:40:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543416020; cv=none; d=google.com; s=arc-20160816; b=Q0gibwOwqM0jryB+i+2ivL7iZle4kHuoQjxQ12aQjrd8/ZEzcym68Xy9dqqZTPCnDG pY8EaiEtkNxn5hSFnKk/MZ3ji0poDPtNXX5W83tpR4oBEaWiadaNfz1dOFhJuOl+9KET AcO3zH2IaH7WM8yQDZaoqWmUe3Ysz3nqts5GrLUFwM14FoR/Wp/rMgAd54hmCOWeeFV1 kre9vr7hgDkVBvTTD6LWvRdjPuFKNhwbCeCUM6m+c0cbtgfF8njCGtNL7S6+ycTW7+wu kT+bCqwa7UikJDha2HCL6m1Ogt8+dvv2722vKUAKGTuyKJ1GQ1nI1p487z+UKI5QEshW oN+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=BWjym5Zw6Nhui/SH8t1ni7k/5hH6H8Cyw7dxMlo9RNI=; b=hVKHgML0UCJGVcHmImykkPNWbAPoDRWAQOx+uwNWLM7SfGmVAeSi4VBIjDllvEHozY quWuqeDb/5OkynCXedtnTFj1CqnDd/52qrbbVHd+gIQfm08xEu491H24WcSCJ03YIozZ Qo8XJg67ICOjGpmRSRJHVeNl+Py3u87gmFvU7C1Vgns9U50uY6Cx1594D/x3ixh+oBXp mbVcm64cLuBfZdx8sNOrxO8Yk30f8rHrsehWRCcmDr7bcZNmSm6owUXaRXogec2n60+J CUqayNaXdps+dJH2lziV27kLicE2HaLIJW2WwcS05eEQtrDOJPl0Fa7GwoaMFZn0UAA7 5Bwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PTvMeyJe; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i67si5274274pfc.148.2018.11.28.06.40.20; Wed, 28 Nov 2018 06:40:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=PTvMeyJe; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728345AbeK2BmM (ORCPT + 15 others); Wed, 28 Nov 2018 20:42:12 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36185 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728223AbeK2BmM (ORCPT ); Wed, 28 Nov 2018 20:42:12 -0500 Received: by mail-pf1-f195.google.com with SMTP id b85so10268506pfc.3 for ; Wed, 28 Nov 2018 06:40:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BWjym5Zw6Nhui/SH8t1ni7k/5hH6H8Cyw7dxMlo9RNI=; b=PTvMeyJe8Gx/X+mw0EsK+fC1KsFerwb0+am18u9SibgV+dvFfuj7oOR8h2Tqe/lp5a qaK8pd8srE0iWETT83fML9IE/3Ub4tfoWqiMv6VLvKpTxYmFQR05ZhpB7yIZs1wznekj 2jP0jyiFUVuscfWeh7qcJWfqajwAdpo6vf4B0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BWjym5Zw6Nhui/SH8t1ni7k/5hH6H8Cyw7dxMlo9RNI=; b=DndpUu2tRn6GHaFGcjus/TDWqsWIBYimR9VF3tcaFyiirJo6jDFHKTM0DZyiOP6DAw FJv5mlnHnyWmFIZlggInbKpNMG/xxiGFWui7dqf57ZwYIgaOWc58S74gWHuNs6kPVjHp 6fYQTvxeL6lyRHWccXrbBnQ7mpAEKcB9kSHp+ETH+zGIFXXAfH2mUnIkm/eOhhnY2WsN LbKJOfOj9CKZuJoTwvf9sh7dQkABUShqtHDcSHefBTTuGs6p2Qpc+NdEyFaUHX8M0KM3 wRzoM3383rueE5NEpMUSUvf8QhoBJu0KzP5tr0fDo/EOsyYfN9zbco+pyC3FXgdnBSN4 gToQ== X-Gm-Message-State: AA+aEWaw7YF6NmOulemcVZTXbQf6411zUmMGVhb2s99p4x0Bfx6sGd22 0OoTj48uBFy1AWVKNPNsWy3Nh4IKtQ4= X-Received: by 2002:a62:30c3:: with SMTP id w186mr5048843pfw.39.1543416018802; Wed, 28 Nov 2018 06:40:18 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id b26sm24227637pfe.91.2018.11.28.06.40.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:40:17 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Amitkumar Karwar , Kalle Valo Subject: [PATCH for-4.9.y 04/10] mwifiex: report error to PCIe for suspend failure Date: Wed, 28 Nov 2018 20:09:58 +0530 Message-Id: <1543416004-1547-5-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> References: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Amitkumar Karwar commit 5190f2e405919cd30ba2f12c58129fb2d71cd6b6 upstream. When host_sleep_config command fails, we should return an error to PCIe, instead of continuing (and possibly panicking, when we try to keep processing a timed-out ioctl after we return "successfully" from suspend). Signed-off-by: Amitkumar Karwar Reviewed-by: Brian Norris Tested-by: Brian Norris Signed-off-by: Kalle Valo Signed-off-by: Amit Pundir --- drivers/net/wireless/marvell/mwifiex/pcie.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index 8b70c909ecbb..cb681b265b10 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -101,7 +101,6 @@ static int mwifiex_pcie_suspend(struct device *dev) { struct mwifiex_adapter *adapter; struct pcie_service_card *card; - int hs_actived; struct pci_dev *pdev = to_pci_dev(dev); if (pdev) { @@ -117,7 +116,14 @@ static int mwifiex_pcie_suspend(struct device *dev) adapter = card->adapter; - hs_actived = mwifiex_enable_hs(adapter); + /* Enable the Host Sleep */ + if (!mwifiex_enable_hs(adapter)) { + mwifiex_dbg(adapter, ERROR, + "cmd: failed to suspend\n"); + adapter->hs_enabling = false; + return -EFAULT; + } + flush_workqueue(adapter->workqueue); /* Indicate device suspended */ From patchwork Wed Nov 28 14:39:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152294 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1170798ljp; Wed, 28 Nov 2018 06:40:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/XMQA1XjED2TSFbPkEYd8A+ka4YwRnWAGhOhUBP1nnExpu7WyU4xrir5tiOblrifh3f5CZ8 X-Received: by 2002:a63:504d:: with SMTP id q13mr33804045pgl.319.1543416023292; Wed, 28 Nov 2018 06:40:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543416023; cv=none; d=google.com; s=arc-20160816; b=IX5Qzif0Kr0HLS4gZh2MY5x0AxeNvqo/2yZV6Ukx6doF2BsLNwkGYklYLfjS28hHa+ Ws2xRMiboStkJlhUCIB9poCXx8vbYimSFPwdyTK8zp+XONAZjT3IoMhUE05qG8iSW6lw Ts1UxRpOOJ+KVwop2Qwms3v4yFHNGEWEuE1cENLwaq4rNg0lmhsxl8s7HeDnc6YZ5X+a qnOQKwEPxat+f7G7pcYJQq90G3EdQ9MTd5+QaxEtq4qcJjVhk/s8mZ3fZvBZQ5UB2gfg b6khmq8qQbic5qTnTQmB0Hl4fyI6pQQfddN2bZY9Hew6NPXGqvT7CmVuKvmSJuNGG+Z2 73LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=TJJM3S/GlfdzGCFa4boe/exQVE5zZNojxEAJ8t7OChw=; b=jrzQy2Bx2ZIeS/tp5YX7+0shFUAG3SfG/VYbGNSqpedjlR8tCQliRAfhgNIUEcb1XB 8KOWfU4zWYSuRzJHDBnTaypNL3Wo5LJE9pHS41YXASN3QVt3blXoPlQM1dn7asgElUTm OtryqrNlrIrJHs7we+FQ6JZq1h+to+tFg0RFkHRUAJNPF4fdIBcmJPUqiKdfDuTkZY1J LfaJZ36tVeogAik4JRJSQcWBG3IuZBXeA5wd3+ulJzVZRcARVFRnTB5c4zGNKF2ui06S HmYaC01dXJwqOf0XKY/qRm2IwofiSgVLJ3JYOOgYKPE03g5Fn+k5ZFzi9AUFnN4+XMlD IYyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ONMBDQhu; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l23si7489048pgh.533.2018.11.28.06.40.23; Wed, 28 Nov 2018 06:40:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=ONMBDQhu; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728413AbeK2BmP (ORCPT + 15 others); Wed, 28 Nov 2018 20:42:15 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:33655 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728223AbeK2BmO (ORCPT ); Wed, 28 Nov 2018 20:42:14 -0500 Received: by mail-pg1-f194.google.com with SMTP id z11so9599315pgu.0 for ; Wed, 28 Nov 2018 06:40:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TJJM3S/GlfdzGCFa4boe/exQVE5zZNojxEAJ8t7OChw=; b=ONMBDQhuMhRiquRM1vAC5JTnbSWhfNf25ZqN5Ml4S7GSO9nDzD3y7ZOcPyzT1ZTPze 09IHypJVh24gTzVZj0HFLdi2ESgqdKbNgWMU/zhMg8K9bUYkpTgXEFm5eAD8p10yi1hq EKsA8xsMm3ILp3NYpd3SA5eig8fHLUOoBHOw0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TJJM3S/GlfdzGCFa4boe/exQVE5zZNojxEAJ8t7OChw=; b=ob1zGObq49q6IlDng34sN2TBt+PBdvp+Irhvx2kbW8cqgs+bivmCM4Nfzc4yAhcMTg bXxozAtd7ANTgqOF1faSh9NPqxsxQ8RfbhJjH1E719VScAFoj7+zW6FN0PqIPjcLQgSC wBGShysDKeISf+bSJztaHauF0npKLt4rxq3IsX7lf4v4F7emfTbjIYlJWNEtAklNBdj8 gudmHb1d7WbOLDlHLV/gEu0x82AGFQPBqgQTZattYiBbmF69rPaMjEY3DciuBkcYjH9p Rnt8XZnZPfOEB4YovyCRRny25MT6tuohC9ZXSXiJfJzPhkxA6+2iHO9pcn+kINtVSpnH OZMA== X-Gm-Message-State: AA+aEWabMsIjV7ag3ZCNUMN2NawHwYh0mN9kNF/96ZWNHrOaG/wBm2Jg 8I4VGak7kt23rX4CiuAXZ6x5ChjRY4I= X-Received: by 2002:a62:29c3:: with SMTP id p186mr5568586pfp.117.1543416021165; Wed, 28 Nov 2018 06:40:21 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id b26sm24227637pfe.91.2018.11.28.06.40.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:40:20 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Amitkumar Karwar , Kalle Valo Subject: [PATCH for-4.9.y 05/10] mwifiex: Fix NULL pointer dereference in skb_dequeue() Date: Wed, 28 Nov 2018 20:09:59 +0530 Message-Id: <1543416004-1547-6-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> References: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Amitkumar Karwar commit c44c040300d7afd79294710313a4989683e2afb1 upstream. At couple of places in cleanup path, we are just going through the skb queue and freeing them without unlinking. This leads to a crash when other thread tries to do skb_dequeue() and use already freed node. The problem is freed by unlinking skb before freeing it. Signed-off-by: Amitkumar Karwar Signed-off-by: Kalle Valo Signed-off-by: Amit Pundir --- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 4 +++- drivers/net/wireless/marvell/mwifiex/wmm.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index 48d51be11f9b..2054948050e2 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -3079,8 +3079,10 @@ int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) mwifiex_stop_net_dev_queue(priv->netdev, adapter); - skb_queue_walk_safe(&priv->bypass_txq, skb, tmp) + skb_queue_walk_safe(&priv->bypass_txq, skb, tmp) { + skb_unlink(skb, &priv->bypass_txq); mwifiex_write_data_complete(priv->adapter, skb, 0, -1); + } if (netif_carrier_ok(priv->netdev)) netif_carrier_off(priv->netdev); diff --git a/drivers/net/wireless/marvell/mwifiex/wmm.c b/drivers/net/wireless/marvell/mwifiex/wmm.c index 0eb246502e1d..dea2fe671dfe 100644 --- a/drivers/net/wireless/marvell/mwifiex/wmm.c +++ b/drivers/net/wireless/marvell/mwifiex/wmm.c @@ -503,8 +503,10 @@ mwifiex_wmm_del_pkts_in_ralist_node(struct mwifiex_private *priv, struct mwifiex_adapter *adapter = priv->adapter; struct sk_buff *skb, *tmp; - skb_queue_walk_safe(&ra_list->skb_head, skb, tmp) + skb_queue_walk_safe(&ra_list->skb_head, skb, tmp) { + skb_unlink(skb, &ra_list->skb_head); mwifiex_write_data_complete(adapter, skb, 0, -1); + } } /* @@ -600,11 +602,15 @@ mwifiex_clean_txrx(struct mwifiex_private *priv) priv->adapter->if_ops.clean_pcie_ring(priv->adapter); spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, flags); - skb_queue_walk_safe(&priv->tdls_txq, skb, tmp) + skb_queue_walk_safe(&priv->tdls_txq, skb, tmp) { + skb_unlink(skb, &priv->tdls_txq); mwifiex_write_data_complete(priv->adapter, skb, 0, -1); + } - skb_queue_walk_safe(&priv->bypass_txq, skb, tmp) + skb_queue_walk_safe(&priv->bypass_txq, skb, tmp) { + skb_unlink(skb, &priv->bypass_txq); mwifiex_write_data_complete(priv->adapter, skb, 0, -1); + } atomic_set(&priv->adapter->bypass_tx_pending, 0); idr_for_each(&priv->ack_status_frames, mwifiex_free_ack_frame, NULL); From patchwork Wed Nov 28 14:40:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152295 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1170849ljp; Wed, 28 Nov 2018 06:40:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/XvJZwPgfm29USJbO7h/FXe9Urz+BhDs7uOkk+cwNn0Dzhn7x4XAoohi7DLt7X1BKgqyF9q X-Received: by 2002:a17:902:6948:: with SMTP id k8mr36763122plt.2.1543416025683; Wed, 28 Nov 2018 06:40:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543416025; cv=none; d=google.com; s=arc-20160816; b=0r+7BUfCv20dSRhso8dObMeKZMBxYy5O0w902vu2qfDtGb3ut/zRphNwgEZG+CUy49 MtcM2upvTzarnOrCsey1MhCc/gfrD2W4Qe4AW5BPWDsM6H5ce4jhdi70mxrfB5VswcbU oVjWVMu7FXcjO9cOaWqmA5mmXaa2bf7Jgd387dsi9MNW+VgRJijOrsq5Pr4ZPPt/1zC1 of+Ui/8YNpLelSiQA8TdhUlOJ1eX7qCdiWSgvTCkEhdDDBGnXUtvEI0AxO9tM1wMWetL UWAnaMno7szzT0nJu5eXbiXnZNmiHypY8iMccJW/yj2YNMIjRiRQSNSgwX4iLw+zApkN k8HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=xxHr+mLY2J0CwMqhv5EY/rzK6JZk0S4t4fOGsDq5K+4=; b=S2M23d/30H7BqakmTt2g8sxQRGhD2671/atsAUXaTTTtiTk+qA+xHcNxM0cKqWpPJd LCRF9pgVKyoIoLM1KVTbUBnAyPj/DEJg7g+YamS5+KP3MxYLK+iDeDewEhr+M1HbGna0 4JlRQCRKLaptXxzR+KGTOhEEa8lcrVFEEFb9FzyKywvNlxnEPR3M5muZ3xUp/sFKHbg2 ksGS6cXV4Mdeprn+0NKBmeAauBoqcgXwmqAAJjX2YVN5nS5J5YPskL/XXubYOnOaMpYc 6prJ7P5hgOZPJpF5zid9reCrD5/1rhSJM2A8H+MjK6m5mru17MT3C/qZKwWinGWeA36s rCNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jVXSYfju; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l23si7489048pgh.533.2018.11.28.06.40.25; Wed, 28 Nov 2018 06:40:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=jVXSYfju; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728442AbeK2BmR (ORCPT + 15 others); Wed, 28 Nov 2018 20:42:17 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:32940 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728223AbeK2BmR (ORCPT ); Wed, 28 Nov 2018 20:42:17 -0500 Received: by mail-pl1-f195.google.com with SMTP id z23so17485011plo.0 for ; Wed, 28 Nov 2018 06:40:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xxHr+mLY2J0CwMqhv5EY/rzK6JZk0S4t4fOGsDq5K+4=; b=jVXSYfjuVMakQuHsvr3JTYyjitiE3PsZatsKkeZmA4BD5WAB18JILda0hPwrgbvw6+ mHMeEv1Y9qHmdJa/D9mG9ZbwqjgR76Fn2LJP4JJXU1oZgG3uEbSQNP2g+1AIc/U1aKAX dSg8U/Dnmjh+Ga0oI4cEIJdk+StM/9plEFHRw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xxHr+mLY2J0CwMqhv5EY/rzK6JZk0S4t4fOGsDq5K+4=; b=NRWzRuHUd8MDsdVMnnqnb1o8Oq1gy2QI4Bl4vcRNxwcSjV7BOyuTDddRtK04n4G/F5 Gq/v1KZi3a0WzsxStkOVGAzUt8Rx1p1FXvUXFvFn7I171wgP0OWEOBjI3WlQ3nFQWBt/ +K0M28PQz6Z2PaeVQAXfgZ2FHctXaLhegNs9oyFv6dm7oNw8h1NyBW0pK/QxpsDSD2ov TLJQS8jMLjsjYTEOZohaL/cUY4cfho8tSFChXk1Gf6d6Sd/dVquFBVy7vngR2ycnvk3U qSCuJhj0Nb62m0mJECZ5YyP8EvXj3e6Dskad0+ahRH3pV8JGJ7+yb+178/KT9RDEz0Wa RovA== X-Gm-Message-State: AA+aEWYSl3LSczUTHpHGjqje8UltqsvcKKWhXGoCQiv8c2xUBQ5Xt6sT R54TnJcG7x6x3kHtUjMe9W6JRQ== X-Received: by 2002:a17:902:7402:: with SMTP id g2mr36488633pll.198.1543416023961; Wed, 28 Nov 2018 06:40:23 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id b26sm24227637pfe.91.2018.11.28.06.40.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:40:22 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Karthik D A , Amitkumar Karwar , Kalle Valo Subject: [PATCH for-4.9.y 06/10] mwifiex: fix p2p device doesn't find in scan problem Date: Wed, 28 Nov 2018 20:10:00 +0530 Message-Id: <1543416004-1547-7-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> References: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Karthik D A commit 3d8bd85c2c9e47ed2c82348aa5b6029ed48376ae upstream. Marvell p2p device disappears from the list of p2p peers on the other p2p device after disconnection. It happens due to a bug in driver. When interface is changed from p2p to station, certain variables(bss_type, bss_role etc.) aren't correctly updated. This patch corrects them to fix the issue. Signed-off-by: Karthik D A Signed-off-by: Amitkumar Karwar Signed-off-by: Kalle Valo Signed-off-by: Amit Pundir --- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.7.4 diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index 2054948050e2..4da3541471e6 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -1209,6 +1209,12 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy, priv->adapter->curr_iface_comb.p2p_intf--; priv->adapter->curr_iface_comb.sta_intf++; dev->ieee80211_ptr->iftype = type; + if (mwifiex_deinit_priv_params(priv)) + return -1; + if (mwifiex_init_new_priv_params(priv, dev, type)) + return -1; + if (mwifiex_sta_init_cmd(priv, false, false)) + return -1; break; case NL80211_IFTYPE_ADHOC: if (mwifiex_cfg80211_deinit_p2p(priv)) From patchwork Wed Nov 28 14:40:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152296 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1170913ljp; Wed, 28 Nov 2018 06:40:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/VAdvSAhU8OxIm1V37VNlATgi/jCEIkRM50d5xhEmNAWKhmFhWS0IvKOp1s8e6A8vuAOl5Z X-Received: by 2002:a17:902:9692:: with SMTP id n18mr14971472plp.333.1543416028870; Wed, 28 Nov 2018 06:40:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543416028; cv=none; d=google.com; s=arc-20160816; b=enqSp+QRgs8g2XfR1A0BrrMi6UE8zu0JZz9ymziKLo9pr8XRzpH4a1NWxztmRNzZ6d IteYXF+zxmmd4eHkCaXl2zZK9EcuFYTARGsVDhBguK6Xsy2DOWmLColw7KIb0wsyVrsL KYFciTGzSmNEECXM3P6PzP7Vrc9w11YuUHFfS3DEHxAcsl/bauzEGgttB3MNUZzS+yui jiSf+sw018ljS31h9E99uP5khDl8dmAKl01zCjnL1iyPjW5PMZCsPgyNr78uJtV82qUu cOjGQ/6pK2052uQrgIlNbN0y39rzhe7yikMIf1PEZ5Re+OKxADcfGbC1lllBWsEKkUtY fDfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=MJLzwpbG1f4M8znpLtghowB6HqNILAu72y4ymu0e+aE=; b=TrYiS29ESy/wnflXtD3i3EwCwkww1oMRX5/IB/WlpCBW/Viup5yAtYwIWoosQ4wjhC C2e01/NghheTulqrIUY+ehslQVMPeobHdkygIKJFE7Hdl4C9BtvqG4s+clui4wYtgviL ZxZSJ5IJp2LXWA3XVS9N+pn6rJaBf4BpnRwoTR0eIcxBVYmP3whtbDPd04ie9G1Apdwb 65UKTacE7AaOs3cI5qJOxszNxm6/8e/qCNR06IHxPeslevF350mIPIQwS7NOQzIq0E/0 3VhypECtNKo9Ema5WK7kLp/tHxDy1N3TSRVmOhyGf6Mghozo98EGRPtNdnOP1PQ195lT kPHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=htJfYjz5; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l23si7489048pgh.533.2018.11.28.06.40.28; Wed, 28 Nov 2018 06:40:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=htJfYjz5; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728458AbeK2BmU (ORCPT + 15 others); Wed, 28 Nov 2018 20:42:20 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46058 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728223AbeK2BmU (ORCPT ); Wed, 28 Nov 2018 20:42:20 -0500 Received: by mail-pf1-f196.google.com with SMTP id g62so10249155pfd.12 for ; Wed, 28 Nov 2018 06:40:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MJLzwpbG1f4M8znpLtghowB6HqNILAu72y4ymu0e+aE=; b=htJfYjz52sn2mVU/FyxbX8mPQj4VXQjWNFlJuqvOMJA4JUPJb3NgfrSzOXDHtr7dBU focmLM7W6YWlW+UIG7JC8ErdCOf4buqRMpI5RjIjQdA9gINTybWgsF/taE5t2hXW2hNL LBZJEkdUZ0Uggd/0lMkUjVXKLav6nt2RKRo0M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MJLzwpbG1f4M8znpLtghowB6HqNILAu72y4ymu0e+aE=; b=K+5Utoo/+HnRljgnUm7PNtlQqFMjoicXfpek4bIWyYGKSwG9PZrOh2l9SLAB8PXu18 aSrkxSvvXyxkUgBfLgtKqFpLY6CHg62IeyzEww4dw6mDZR8BnjUnJEJ8O+AS/DBsaE7m dx6eoL6CsDtt7X0yKDdG/sodBxyCyojxzPg73KOW7iLZX3pGsrNqnrKk+mk62rTR7qqi ftRY8IOF5eoIar9fuAkzNmgXfQ3sGadx2kLIElSjyzIt4a0netGwqeujveCxFW5QAnTT pK7qTzsuZXT0VkpcqWhpMFpzsyAP5mQ5BJZd0yY17VBsQS58Uma7mhGCAC3OhlhrLujk Olwg== X-Gm-Message-State: AA+aEWbqcco4IuzJ9sFxZjYSxFZUG2NJKhHTgS//7RI7Jx5UFIUDqpLY MGNcHEZ80dgW4LtjIlhlBICRNw== X-Received: by 2002:a63:8149:: with SMTP id t70mr28391012pgd.172.1543416026736; Wed, 28 Nov 2018 06:40:26 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id b26sm24227637pfe.91.2018.11.28.06.40.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:40:25 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Yaniv Gardi , Subhash Jadavani , "Martin K . Petersen" Subject: [PATCH for-4.9.y 07/10] scsi: ufs: fix bugs related to null pointer access and array size Date: Wed, 28 Nov 2018 20:10:01 +0530 Message-Id: <1543416004-1547-8-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> References: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yaniv Gardi commit e3ce73d69aff44421d7899b235fec5ac2c306ff4 upstream. In this change there are a few fixes of possible NULL pointer access and possible access to index that exceeds array boundaries. Signed-off-by: Yaniv Gardi Signed-off-by: Subhash Jadavani Signed-off-by: Martin K. Petersen Signed-off-by: Amit Pundir --- drivers/scsi/ufs/ufs.h | 3 ++- drivers/scsi/ufs/ufshcd.c | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index 5bb2316f60bf..54deeb754db5 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -46,6 +46,7 @@ #define QUERY_DESC_HDR_SIZE 2 #define QUERY_OSF_SIZE (GENERAL_UPIU_REQUEST_SIZE - \ (sizeof(struct utp_upiu_header))) +#define RESPONSE_UPIU_SENSE_DATA_LENGTH 18 #define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\ cpu_to_be32((byte3 << 24) | (byte2 << 16) |\ @@ -410,7 +411,7 @@ struct utp_cmd_rsp { __be32 residual_transfer_count; __be32 reserved[4]; __be16 sense_data_len; - u8 sense_data[18]; + u8 sense_data[RESPONSE_UPIU_SENSE_DATA_LENGTH]; }; /** diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index f857086ce2fa..5a1ea5aa799e 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -901,10 +901,14 @@ static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp) int len; if (lrbp->sense_buffer && ufshcd_get_rsp_upiu_data_seg_len(lrbp->ucd_rsp_ptr)) { + int len_to_copy; + len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len); + len_to_copy = min_t(int, RESPONSE_UPIU_SENSE_DATA_LENGTH, len); + memcpy(lrbp->sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data, - min_t(int, len, SCSI_SENSE_BUFFERSIZE)); + min_t(int, len_to_copy, SCSI_SENSE_BUFFERSIZE)); } } @@ -6373,7 +6377,10 @@ EXPORT_SYMBOL(ufshcd_system_suspend); int ufshcd_system_resume(struct ufs_hba *hba) { - if (!hba || !hba->is_powered || pm_runtime_suspended(hba->dev)) + if (!hba) + return -EINVAL; + + if (!hba->is_powered || pm_runtime_suspended(hba->dev)) /* * Let the runtime resume take care of resuming * if runtime suspended. @@ -6394,7 +6401,10 @@ EXPORT_SYMBOL(ufshcd_system_resume); */ int ufshcd_runtime_suspend(struct ufs_hba *hba) { - if (!hba || !hba->is_powered) + if (!hba) + return -EINVAL; + + if (!hba->is_powered) return 0; return ufshcd_suspend(hba, UFS_RUNTIME_PM); @@ -6424,10 +6434,13 @@ EXPORT_SYMBOL(ufshcd_runtime_suspend); */ int ufshcd_runtime_resume(struct ufs_hba *hba) { - if (!hba || !hba->is_powered) + if (!hba) + return -EINVAL; + + if (!hba->is_powered) return 0; - else - return ufshcd_resume(hba, UFS_RUNTIME_PM); + + return ufshcd_resume(hba, UFS_RUNTIME_PM); } EXPORT_SYMBOL(ufshcd_runtime_resume); From patchwork Wed Nov 28 14:40:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152297 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1170951ljp; Wed, 28 Nov 2018 06:40:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/UtHoOOO6eqpWxI1cxj5Yd/kY1sQ+QtUM6fC2vlhTdIoPhxtJmxfNU/Q9SSSX06sPdd0EmI X-Received: by 2002:a17:902:a03:: with SMTP id 3mr24934291plo.112.1543416031468; Wed, 28 Nov 2018 06:40:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543416031; cv=none; d=google.com; s=arc-20160816; b=t2ztDHy1H/l9uVHIsQ/aVlo9w3GoilhcvTSnl2O9eCeo/eSovyHReFPnzlA7DYWacU x/qqKfc9PPosdtuTxartQp9LH/TQl8IFiSDotA3C6l4u0uBrn3mYPRSSUFo4gohG33wB naqdKMJWxdheEDhGnNLbBPchhnugkxzV1rrdSAHHevdoFPhK/5Y7N9DAqP86yjlm6Rqi 3VPONC+vS1tjzwFX48s0Z3o/xJG35CR0e+Wq6H+uJSzYJ50xIuy7UBwnDlfcNNlKXFd5 pZODI5oI6oNl5vadYrBG6Fy3MnXY/QZn+KCBhl++y9h4TjZ84Zx7W7H3Llnx6IaDiKsd tU/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=8/oszXCEEU9n8169o7c5KKdnJY4IbNKiR1WhSfUs5xo=; b=D/FunhPwyxrsnobd4AG9+lPVVcy6roMDrT6LhPiz9V3c/cvHDb/+1AaBeNPVw4Jzq1 Ggv1qbd8UJb10h2Im8G2JZFofE5vp2kE7dWKmlA5TdhKIp2DFn022DxL7ssgAN34/8IO Pu64sUFrTOUfYsevctoZzEasyI+ao1miYL1WedbnFjxpj0Y7c5YwZpziFDaQ5TKv6/5E eAgITUFL9+yutAzkjHGYXKWBg6oJO2VlZaWLtKu4V7VLlLC0j6gedWRBlFMVpv6nCHUW MVaFqpvWYLbncuYpTZirUCGm+aRhf4rCjt+o+XXzFh3kdMGjZOOu0cz8+sD1+Fa1ou9q NDoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YkzJZcBa; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l23si7489048pgh.533.2018.11.28.06.40.31; Wed, 28 Nov 2018 06:40:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=YkzJZcBa; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728572AbeK2BmX (ORCPT + 15 others); Wed, 28 Nov 2018 20:42:23 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36401 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727941AbeK2BmX (ORCPT ); Wed, 28 Nov 2018 20:42:23 -0500 Received: by mail-pg1-f196.google.com with SMTP id n2so9598818pgm.3 for ; Wed, 28 Nov 2018 06:40:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8/oszXCEEU9n8169o7c5KKdnJY4IbNKiR1WhSfUs5xo=; b=YkzJZcBaummHcKcechzc7ScUDLZRrwU3woscO6c593ZjcnUK8uNda0cIQlcThYPMcc 1MEIQh1tVXbz0hlabuXxVCI/P7GXdNOdk2N+ENi+rWWxvoRJ+2ervYXhhpL/Qiyg0/HQ 0j5MQilDiVFCmDPOOI7l0BEhgN+t8vKSwpSys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8/oszXCEEU9n8169o7c5KKdnJY4IbNKiR1WhSfUs5xo=; b=B8sdbHMahaPvli14+/rCQiqcwMBWVq+2tcW4eJcw0QP/oFI4y323D54I24nxB8oU4d MspcwswQ1sQFh+yaQpyZ/Ua/2B6T2MPzpCrR6t0Yy2mmqqn7wUfjol1Z7jZQ6ho3+/gg lJ/+whdpz1WzrILpfmv7aLULCHyYmbpLw0xfGU5jxw4j8KzLi5rfzey4YOIXsT6Hr4lO gdFmOqF7+jUqyloBq+G5qtfrzpR6Zhi8VbXpCtccMSkKaNlfgHOByR4iurJ9JyfXxBN/ X5qqJCn/ckcffBO452v0iP8yDSILEj7os/aDGwhXHVhOj4eV7FeTBv/oQknBzSzr09Gz FVvw== X-Gm-Message-State: AA+aEWZtim/sblE0rjsXlwhIcvjgIIjryTsYnAYZTEkkiJ68It9IN37M QG4R9XmGE0bPTVX9v5Br4tGk3A== X-Received: by 2002:a63:1c09:: with SMTP id c9mr32970190pgc.200.1543416029472; Wed, 28 Nov 2018 06:40:29 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id b26sm24227637pfe.91.2018.11.28.06.40.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:40:28 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Venkat Gopalakrishnan , Subhash Jadavani , "Martin K . Petersen" Subject: [PATCH for-4.9.y 08/10] scsi: ufshcd: Fix race between clk scaling and ungate work Date: Wed, 28 Nov 2018 20:10:02 +0530 Message-Id: <1543416004-1547-9-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> References: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Venkat Gopalakrishnan commit f2a785ac23125fa0774327d39e837e45cf28fe92 upstream. The ungate work turns on the clock before it exits hibern8, if the link was put in hibern8 during clock gating work. There occurs a race condition when clock scaling work calls ufshcd_hold() to make sure low power states cannot be entered, but that returns by checking only whether the clocks are on. This causes the clock scaling work to issue UIC commands when the link is in hibern8 causing failures. Make sure we exit hibern8 state before returning from ufshcd_hold(). Callstacks for race condition: ufshcd_scale_gear ufshcd_devfreq_scale ufshcd_devfreq_target update_devfreq devfreq_monitor process_one_work worker_thread kthread ret_from_fork ufshcd_uic_hibern8_exit ufshcd_ungate_work process_one_work worker_thread kthread ret_from_fork Signed-off-by: Venkat Gopalakrishnan Signed-off-by: Subhash Jadavani Signed-off-by: Martin K. Petersen Signed-off-by: Amit Pundir --- drivers/scsi/ufs/ufshcd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) -- 2.7.4 diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 5a1ea5aa799e..6130e10145b5 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -672,6 +672,21 @@ int ufshcd_hold(struct ufs_hba *hba, bool async) start: switch (hba->clk_gating.state) { case CLKS_ON: + /* + * Wait for the ungate work to complete if in progress. + * Though the clocks may be in ON state, the link could + * still be in hibner8 state if hibern8 is allowed + * during clock gating. + * Make sure we exit hibern8 state also in addition to + * clocks being ON. + */ + if (ufshcd_can_hibern8_during_gating(hba) && + ufshcd_is_link_hibern8(hba)) { + spin_unlock_irqrestore(hba->host->host_lock, flags); + flush_work(&hba->clk_gating.ungate_work); + spin_lock_irqsave(hba->host->host_lock, flags); + goto start; + } break; case REQ_CLKS_OFF: if (cancel_delayed_work(&hba->clk_gating.gate_work)) { From patchwork Wed Nov 28 14:40:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152298 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1170991ljp; Wed, 28 Nov 2018 06:40:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/UjiIVwjDCkX+6Ama4e72TckbFp9I2VcWWdORed/QkXj6NAPcwOOaAObcmFzqcvm0lThTXS X-Received: by 2002:a17:902:45:: with SMTP id 63mr35751383pla.272.1543416033638; Wed, 28 Nov 2018 06:40:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543416033; cv=none; d=google.com; s=arc-20160816; b=rIz5cliUHqXfSXceDpc2yHCFMkBB/+s5/EMI/FLH8UWc++Q2AD/bfySbgwxK39nzcr Ola7cIJscWra0OipHinLyLfBEU8BTKYXhBlBeFs25Em03r7FSooq6+WCiJK6+Vz+/IM1 T08Feh6NdWvnFIupIS92HIiGweDVLOzHZVCzhjvnFSq4Z/IO8BjadxGSegpWJ4c4N+A6 xcuDEfIcT+8rb09XMfaOBhlM1BEiAhWzrWdyx/JpID+X29nqyjqy8YC3zFTfd/3OH/La 9F4ETUjTMJiVGxM25YVIBwn7naFQi9E+yI1XYLc6xIhv4ZFpKj0D7Ih1XlDJ81q61zPs KNvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=nm52e4sRydvQo9X2NaxI6PWe3nPLLEMjzASU47pmhn4=; b=LwXqf52Lkob/7xmfnmZOtZKCHSpIQBQWs0UZbC0RvFQ7QTeupY027f75WkXCyL94Jt A88SeZ01xhPAzCE4YfPOxrL4Is+uH1jNgyRg+g0MfMi39pDbxsldPrkiY24C8S5RV3Xx pO7sTuWLKPzp50BiUzWCpIrVzjB+zufdmQl31H+KOKhFlyRGSWjAyz7qA5rdBTZg8tE0 Fujnqhvomvp+KCXDs+jbO7uZ2ywKFU0K6DAOfFBhE/WoP0eHc8Ci3SXaPcwaGMmubzWI /d1v3MKto1TD9L/9Dxz7ZowkeoUd+oSR/SahFPJ3qZGAhqaNXwk2zoEwGTdZCga0PuBw O6Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kurKaQnJ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l23si7489048pgh.533.2018.11.28.06.40.33; Wed, 28 Nov 2018 06:40:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=kurKaQnJ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728223AbeK2BmZ (ORCPT + 15 others); Wed, 28 Nov 2018 20:42:25 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41283 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727941AbeK2BmZ (ORCPT ); Wed, 28 Nov 2018 20:42:25 -0500 Received: by mail-pl1-f193.google.com with SMTP id u6so17481247plm.8 for ; Wed, 28 Nov 2018 06:40:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nm52e4sRydvQo9X2NaxI6PWe3nPLLEMjzASU47pmhn4=; b=kurKaQnJd05/OfkQ3OxJx/pb3IqV3NvQmb+xMbMNgqXm9/2wGFNJ/v4zxSRfXj73DR jB4CdRPddNM/RMFbZyeh9cAR/OFFRz8zZqXYhlu6p1W8ejRHUArGYSudEWSed1UFZ3SF AsRPwhDYU5XcoI59lNG9otJdCn+VzLrs5Wj9Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nm52e4sRydvQo9X2NaxI6PWe3nPLLEMjzASU47pmhn4=; b=FNEagRztsunRBg7C4WJxIgLZWiXCnlob/sv4zmVJGgSCABqG7SnrIlOkAMruCgF+v7 uu3HGlcY6JlJDnzCdHig5dMoLttD/zynFiKLGbgRD0/Xje59+lLgUrcicmHhs94DQPil iStiwBoT249twd9UgsbEmBseHaEPWhv3xNEpOlPTQppk4Gknnedqq89u56qIeNGzrinT lFVZ3n2FSECVi1RdOOtwXAorRbXtjXbC6b8v+aOsXBlUJpyP4jlVqhzkRhlbaSZ26AoP /rGx1cY8pC/D1UCzlDEUg2PO3x1jRb7VYE4rgzchrKhuN3HuhNyJ15LZfe7IBg4+Be14 Bvdw== X-Gm-Message-State: AA+aEWaTg7svh2atHlimkZUr5ZeT5FbGUVG/8gKYppSezR/MpZkCSZsp shBo3k6HAqSxOhW7Q6CReN9TFw== X-Received: by 2002:a17:902:8687:: with SMTP id g7mr10743421plo.96.1543416031879; Wed, 28 Nov 2018 06:40:31 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id b26sm24227637pfe.91.2018.11.28.06.40.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:40:31 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Subhash Jadavani , "Martin K . Petersen" Subject: [PATCH for-4.9.y 09/10] scsi: ufs: fix race between clock gating and devfreq scaling work Date: Wed, 28 Nov 2018 20:10:03 +0530 Message-Id: <1543416004-1547-10-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> References: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Subhash Jadavani commit 30fc33f1ef475480dc5bea4fe1bda84b003b992c upstream. UFS devfreq clock scaling work may require clocks to be ON if it need to execute some UFS commands hence it may request for clock hold before issuing the command. But if UFS clock gating work is already running in parallel, ungate work would end up waiting for the clock gating work to finish and as clock gating work would also wait for the clock scaling work to finish, we would enter in deadlock state. Here is the call trace during this deadlock state: Workqueue: devfreq_wq devfreq_monitor __switch_to __schedule schedule schedule_timeout wait_for_common wait_for_completion flush_work ufshcd_hold ufshcd_send_uic_cmd ufshcd_dme_get_attr ufs_qcom_set_dme_vs_core_clk_ctrl_clear_div ufs_qcom_clk_scale_notify ufshcd_scale_clks ufshcd_devfreq_target update_devfreq devfreq_monitor process_one_work worker_thread kthread ret_from_fork Workqueue: events ufshcd_gate_work __switch_to __schedule schedule schedule_preempt_disabled __mutex_lock_slowpath mutex_lock devfreq_monitor_suspend devfreq_simple_ondemand_handler devfreq_suspend_device ufshcd_gate_work process_one_work worker_thread kthread ret_from_fork Workqueue: events ufshcd_ungate_work __switch_to __schedule schedule schedule_timeout wait_for_common wait_for_completion flush_work __cancel_work_timer cancel_delayed_work_sync ufshcd_ungate_work process_one_work worker_thread kthread ret_from_fork This change fixes this deadlock by doing this in devfreq work (devfreq_wq): Try cancelling clock gating work. If we are able to cancel gating work or it wasn't scheduled, hold the clock reference count until scaling is in progress. If gate work is already running in parallel, let's skip the frequecy scaling at this time and it will be retried once next scaling window expires. Reviewed-by: Sahitya Tummala Signed-off-by: Subhash Jadavani Signed-off-by: Martin K. Petersen Signed-off-by: Amit Pundir --- drivers/scsi/ufs/ufshcd.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) -- 2.7.4 diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 6130e10145b5..39732e93d460 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6633,15 +6633,47 @@ static int ufshcd_devfreq_target(struct device *dev, { int err = 0; struct ufs_hba *hba = dev_get_drvdata(dev); + bool release_clk_hold = false; + unsigned long irq_flags; if (!ufshcd_is_clkscaling_enabled(hba)) return -EINVAL; + spin_lock_irqsave(hba->host->host_lock, irq_flags); + if (ufshcd_eh_in_progress(hba)) { + spin_unlock_irqrestore(hba->host->host_lock, irq_flags); + return 0; + } + + if (ufshcd_is_clkgating_allowed(hba) && + (hba->clk_gating.state != CLKS_ON)) { + if (cancel_delayed_work(&hba->clk_gating.gate_work)) { + /* hold the vote until the scaling work is completed */ + hba->clk_gating.active_reqs++; + release_clk_hold = true; + hba->clk_gating.state = CLKS_ON; + } else { + /* + * Clock gating work seems to be running in parallel + * hence skip scaling work to avoid deadlock between + * current scaling work and gating work. + */ + spin_unlock_irqrestore(hba->host->host_lock, irq_flags); + return 0; + } + } + spin_unlock_irqrestore(hba->host->host_lock, irq_flags); + if (*freq == UINT_MAX) err = ufshcd_scale_clks(hba, true); else if (*freq == 0) err = ufshcd_scale_clks(hba, false); + spin_lock_irqsave(hba->host->host_lock, irq_flags); + if (release_clk_hold) + __ufshcd_release(hba); + spin_unlock_irqrestore(hba->host->host_lock, irq_flags); + return err; } From patchwork Wed Nov 28 14:40:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152299 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1171025ljp; Wed, 28 Nov 2018 06:40:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/VfsvwuHzNFIQYeDbZkJmTfefEbWaB4fNRZoGh78S6L97U8EpWYY8jLnrGf4n8xUdfIY8KQ X-Received: by 2002:a17:902:720c:: with SMTP id ba12mr20610653plb.79.1543416035658; Wed, 28 Nov 2018 06:40:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543416035; cv=none; d=google.com; s=arc-20160816; b=yM/zEupqwy3wnJIoHpHfAPj7rVAy3dd0gBlpSJ1zDre+TrenVPZc26QjZkhaX/8ZZ4 ilztXT2bQ6aLpk6I7mF+5QJaNC9mwpOtor1xtpeNRToUWaGKzYxp0oiZawJsscgA9+0t 5+4OdVpEh+Eqilio1esCKhUBxvruSaRr8BVWKjFaLwbswURlrq5/IAOLrSiw+cE14lF6 WcOI/xzLV/V1/MnfIU7ssH1qcHfdNxKJDSQdZHDH3UquKKAMOGI4hmGarvUhd8RQyLZJ gFyb0DYy0+8ly07gTacJPzR8j7M0XHZmawkagV3cuwdVYhNzzQNmCVqlaxDprL/hemea mCqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=6xt0TBs45e/9YTcYGwApVbLQoJIHwf7ONWA1rPhxQGk=; b=Aa6AdYjcmD00GPedEE4lk/utXfCFC6dl9HqlSMAYzJ3VYbOwCNoTTz/wP8hPzyGLnj sGOYDNouj08UJAKJgm7PRa+jNsBXu0XPNtXcvYUWh7NcTB4d1nln1Pg+nuVCLnhVZrA1 ZutpOacgY4wbUBplQlaQ34Dm/btzXNL1WSyncMAra1/gDqlEXKvJGhY4fISzk9x4AJKF bZrxujHlP8bbGjnbYIQDpm8+l2gKIkJJ6wN6Ec6EcKbQZ6KWeUk0/UjCSDy5aeI/hHCk u8f7EIaw71NFbt4bF81PdL9E9FErzNa/WqDVui0o5k6VLYZ3oqlqdg1FtAgw4fjgF+2u hTZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e0TILW0n; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l23si7489048pgh.533.2018.11.28.06.40.35; Wed, 28 Nov 2018 06:40:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=e0TILW0n; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727941AbeK2Bm1 (ORCPT + 15 others); Wed, 28 Nov 2018 20:42:27 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45851 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728443AbeK2Bm1 (ORCPT ); Wed, 28 Nov 2018 20:42:27 -0500 Received: by mail-pl1-f194.google.com with SMTP id a14so17457998plm.12 for ; Wed, 28 Nov 2018 06:40:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6xt0TBs45e/9YTcYGwApVbLQoJIHwf7ONWA1rPhxQGk=; b=e0TILW0nRiOlPhRFTizOIwftxoclpgeWQnOhSkEsj/xwiFYVYxMyacsS8u0ERHh9rv qYnSJUI90drUc/EIomozUE8v3ghYNvFCKqLSr0IZrfcNE32YLWFdfnNVLc7s/36JlUzd +WuwzhRdsTA/hK2PmB2RfGUGnvX57lDoWZ25Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6xt0TBs45e/9YTcYGwApVbLQoJIHwf7ONWA1rPhxQGk=; b=YeMMHF293+yeeXCv1IPskMS2ZF93SPUsIlxm9WAlnLA/2/V14F3IZ6wNz/nI+aGcdx pwbUORzVHRLuegu39hYGKCjsU0jHyib4S/2FOoGvW5FlvCuv/rU+PP/Vra5V8qHDWzRn r2WkolUz3r6+UPhoqY92ex7LKYXEfxZ3Mjlk+zI5iaURTlaAaU99m/SJH7UgiPbLOO3K kpLuHiY/P5b9Xm0GXeFHeRv8PI1IbMPbLMf0EEMofqBmG/jXTktqAGZpM/cJodJplmb9 bf8TXikLm0u0y4uprxJ8mQGX03o0aeh3y+jJSiLoKsS5pduPDbUCdI0PoKa+zUs6I1mw 9khQ== X-Gm-Message-State: AA+aEWZLukY+vmeLyhbz1JchgEIaW9eHvbdaiA98Uimur+/Vz/gTPTbS WFTMInwz+PwhleDXlBBTXWEvHA== X-Received: by 2002:a17:902:d891:: with SMTP id b17mr37851787plz.80.1543416034279; Wed, 28 Nov 2018 06:40:34 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id b26sm24227637pfe.91.2018.11.28.06.40.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:40:33 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Subhash Jadavani , "Martin K . Petersen" Subject: [PATCH for-4.9.y 10/10] scsi: ufshcd: release resources if probe fails Date: Wed, 28 Nov 2018 20:10:04 +0530 Message-Id: <1543416004-1547-11-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> References: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Subhash Jadavani commit afa3dfd42d205b106787476647735aa1de1a5d02 upstream. If ufshcd pltfrm/pci driver's probe fails for some reason then ensure that scsi host is released to avoid memory leak but managed memory allocations (via devm_* calls) need not to be freed explicitly on probe failure as memory allocated with these functions is automatically freed on driver detach. Reviewed-by: Sahitya Tummala Signed-off-by: Subhash Jadavani Signed-off-by: Martin K. Petersen Signed-off-by: Amit Pundir --- drivers/scsi/ufs/ufshcd-pci.c | 2 ++ drivers/scsi/ufs/ufshcd-pltfrm.c | 5 +---- drivers/scsi/ufs/ufshcd.c | 3 --- 3 files changed, 3 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c index d15eaa466c59..52b546fb509b 100644 --- a/drivers/scsi/ufs/ufshcd-pci.c +++ b/drivers/scsi/ufs/ufshcd-pci.c @@ -104,6 +104,7 @@ static void ufshcd_pci_remove(struct pci_dev *pdev) pm_runtime_forbid(&pdev->dev); pm_runtime_get_noresume(&pdev->dev); ufshcd_remove(hba); + ufshcd_dealloc_host(hba); } /** @@ -147,6 +148,7 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) err = ufshcd_init(hba, mmio_base, pdev->irq); if (err) { dev_err(&pdev->dev, "Initialization failed\n"); + ufshcd_dealloc_host(hba); return err; } diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c index db53f38da864..a72a4ba78125 100644 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c @@ -163,7 +163,7 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name, if (ret) { dev_err(dev, "%s: unable to find %s err %d\n", __func__, prop_name, ret); - goto out_free; + goto out; } vreg->min_uA = 0; @@ -185,9 +185,6 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name, goto out; -out_free: - devm_kfree(dev, vreg); - vreg = NULL; out: if (!ret) *out_vreg = vreg; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 39732e93d460..5cfd56f08ffb 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6507,8 +6507,6 @@ void ufshcd_remove(struct ufs_hba *hba) ufshcd_disable_intr(hba, hba->intr_mask); ufshcd_hba_stop(hba, true); - scsi_host_put(hba->host); - ufshcd_exit_clk_gating(hba); if (ufshcd_is_clkscaling_enabled(hba)) devfreq_remove_device(hba->devfreq); @@ -6876,7 +6874,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) ufshcd_exit_clk_gating(hba); out_disable: hba->is_irq_enabled = false; - scsi_host_put(host); ufshcd_hba_exit(hba); out_error: return err;