From patchwork Thu Feb 25 10:13:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 387208 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp188535jap; Thu, 25 Feb 2021 02:08:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6YgsM76WMz29MprX9pmBkEbxeXUMiyQyMd77a9/92N3vsk9id7jWzvGM+sfr4LJemvms8 X-Received: by 2002:aa7:c044:: with SMTP id k4mr2075260edo.47.1614247736905; Thu, 25 Feb 2021 02:08:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614247736; cv=none; d=google.com; s=arc-20160816; b=rJn1awTajDpRqjdPBCNxR9yQWKMzHJKB3n9cYhiUspB6TyKghmOb6CDfgkiWDRK++K 9Q+uyt2D4M/oLtTjvQg51uF7fwpdwhyXUhmaCqIKKdtfssgJsbMuoZPbRyRXexDvmF1+ psH3KENybuWGytOfOSxBK0Cx7OU/Nq+6hJEvcvGVJTYAh+d99CVHuv9ievEbBczQ7Wnx BAt/N5ix6cX9B5hcRcOGvWqvLCUG0aE87Rcz3OZie2oPKEsNy7p4x3mYoiYTVr8OMXPB Q8SVPjnDiMmC550SsnOU1DfnsP3P718dxNxQH2GBfSawfI9vF9iOQyKKmuxhE5Ji1jY9 vsQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=gaa+HntJuQ6rmQhc7jzPfrBWIm/FecwgprQWh1KwhLg=; b=cuQZWJjYKqPzqDquTrIoT2S1Pg3/QAnJIEBGlqFVQwKxKejl/QKw2bVZQYLxKRreTC xeIJK7DkLRPeeCzI0kZ7BmsN7qzB764fp00b4Lxjni4LhRQvahZizntSnIYA753SLiwM eHthcOwdI/O0u9XpBhBSUtdnfpseB9etm/w+z9JHybhOiCHTd8tdWyXg1LeqAoIkNyQp MH5Iwkq9QkHCr8KpIZ8oqH7K4BlorZJJzPijJHq4TT+YiZIG0Zo9b02sArDysOFXh9bQ 0VlDZBXL995eSDMsd1gPGs3MNeTH66U8K8rWwIDWEchIsNpyDDm9C76TgpJ9HYPXU7KY saNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ktq5TQBk; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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. [23.128.96.18]) by mx.google.com with ESMTP id q22si3224118ejj.278.2021.02.25.02.08.56; Thu, 25 Feb 2021 02:08:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ktq5TQBk; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S232296AbhBYKIb (ORCPT + 16 others); Thu, 25 Feb 2021 05:08:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233805AbhBYKFY (ORCPT ); Thu, 25 Feb 2021 05:05:24 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7068C06174A for ; Thu, 25 Feb 2021 02:04:42 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id g11so399787wmh.1 for ; Thu, 25 Feb 2021 02:04:42 -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; bh=gaa+HntJuQ6rmQhc7jzPfrBWIm/FecwgprQWh1KwhLg=; b=Ktq5TQBkxnsDBwxrRDmcizGhWh/xIHYmNZBSoG700gjSLL7K8HP+xd3JYLXCnzxlGo TeDoO2WvnxDyEtbKTXfud6L3AcYrog/iqmP4BDdiIh2AU/NsSmUfWtT9qjxKk6m3Si75 HBG80pHnzlxUx4o/CznbhxR6u06q6xTJEzm4HwtDJKnSO9+cs1LPt/wnTCcmrvKzu05g mNK/IbqnV9H1Dvr24/2UjbBcGF1TtKA1rYnenlvoMzv2O7nlNMSfhqhGtaJ17n2pvVVt MaVsT5AFMGmQ55USgaR4nMTJeP84v2RkvhrIYWXtQQq2ru5HoScdKqJIlagg760hr7YZ aQXQ== 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; bh=gaa+HntJuQ6rmQhc7jzPfrBWIm/FecwgprQWh1KwhLg=; b=qepdNwrMvJKtujH/Ck7oe9uzZwfW7XY7D2yQiKopB6Thabfv3Krmu1Hsljmp/DfUKW MqUg6bq7gBMy390K5DZaii7Ize9bEY2d+QFNOMym8wgBOYn6ClAhjt7YjGfpV02jQ+HZ c9fX+ggasPudf58kJ5eq56inUctWf7BuUtcCBOE8OshxmDwoCGnrzsbcXqUufUPRk5BT D94F1RCw5dGUg81Aapo4AmaEbJvByhIdKTqNkEImxsh4oHm/W1KMTO/JsVPogumIHIoo hs+jGBAGgxC7tP8RalDoPXT+QRJligVzJ4FxZqoI9PiEjmSmfkwA+H5y5r1wsp9wvBNZ l8vw== X-Gm-Message-State: AOAM5311vMckWl6XwXQ5modZOFwI1jyuuKtdqnEuHa9UjT5/eAmwdO5Y 3yovXqWGJt4AsBQsNMVfZBoKM34HuvZ05def X-Received: by 2002:a05:600c:3516:: with SMTP id h22mr2437851wmq.35.1614247481513; Thu, 25 Feb 2021 02:04:41 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:82c:5f0:6732:e420:1382:85f4]) by smtp.gmail.com with ESMTPSA id z82sm5163373wmg.19.2021.02.25.02.04.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Feb 2021 02:04:41 -0800 (PST) From: Loic Poulain To: manivannan.sadhasivam@linaro.org, hemantk@codeaurora.org Cc: linux-arm-msm@vger.kernel.org, Loic Poulain Subject: [PATCH] mhi: Fix invalid error returning in mhi_queue Date: Thu, 25 Feb 2021 11:13:00 +0100 Message-Id: <1614247980-1776-1-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org mhi_queue returns an error when the doorbell is not accessible in the current state. This can happen when the device is in non M0 state, like M3, and needs to be waken-up prior ringing the DB. this case is manager earlier by triggering an asynchronous M3 exit via controller resume/suspend callbacks, that in turn will cause M0 transition and DB update. So, since it's not an error but just delaying of doorbell update do not return an error. That also fix a use after free error for skb case, indeed a caller queuing skb will try to free the skb if the queueing fails, but in that case queueing has been done. Signed-off-by: Loic Poulain --- drivers/bus/mhi/core/main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) -- 2.7.4 Reviewed-by: Jeffrey Hugo Reviewed-by: Bhaumik Bhatt diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index 7fc2482..c780234 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -1031,12 +1031,8 @@ static int mhi_queue(struct mhi_device *mhi_dev, struct mhi_buf_info *buf_info, if (mhi_chan->dir == DMA_TO_DEVICE) atomic_inc(&mhi_cntrl->pending_pkts); - if (unlikely(!MHI_DB_ACCESS_VALID(mhi_cntrl))) { - ret = -EIO; - goto exit_unlock; - } - - mhi_ring_chan_db(mhi_cntrl, mhi_chan); + if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl))) + mhi_ring_chan_db(mhi_cntrl, mhi_chan); exit_unlock: read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags);