From patchwork Mon Oct 28 08:06:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13853138 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 144CF1917D8; Mon, 28 Oct 2024 08:06:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730102818; cv=none; b=pVaa70PxEAeYK+/wVStF1yX2jFG8AMk3vEn9nM4ZYkxnht3PizITatQi8PKD4usN0q9+dn3rE8TU1RgAaXarls/6J/5wQQUjbbdoePc+bgYIAAT9WE5UnO4vdGazznjvwx9YhUvbLp1s/odEGxWZEQvEI8lans7NSeVoYp2unBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730102818; c=relaxed/simple; bh=30EIEzsbTiM7pdJuXATL4PYo2bASkKIMoENwNv7p/Hs=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=V2tuav8okr3k6aA1vIVj0g/xXlOzP0F5JEJa9yn0UHGoDWkFKSq7ywBWt1xCS9Ddkrg5jlKGNGsyWFf6wuBBVlWrrHoP8FrxWO49du/bURopEYzKgYtSaI5doNI40QTuwinovIaCkaa1Fs6Ptd6nHdahh2SCkliqqrwZ8rydJmM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4XcQsN0whrz1T9Bq; Mon, 28 Oct 2024 16:04:40 +0800 (CST) Received: from kwepemg200008.china.huawei.com (unknown [7.202.181.35]) by mail.maildlp.com (Postfix) with ESMTPS id 2D1F21800DE; Mon, 28 Oct 2024 16:06:48 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemg200008.china.huawei.com (7.202.181.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 28 Oct 2024 16:06:47 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , CC: Subject: [PATCH net] net: wwan: t7xx: off-by-one error in t7xx_dpmaif_rx_buf_alloc() Date: Mon, 28 Oct 2024 16:06:18 +0800 Message-ID: <20241028080618.3540907-1-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemg200008.china.huawei.com (7.202.181.35) X-Patchwork-Delegate: kuba@kernel.org The error path in t7xx_dpmaif_rx_buf_alloc(), free and unmap the already allocated and mapped skb in a loop, but the loop condition terminates when the index reaches zero, which fails to free the first allocated skb at index zero. Check for >= 0 so that skb at index 0 is freed as well. Fixes: d642b012df70 ("net: wwan: t7xx: Add data path interface") Signed-off-by: Jinjie Ruan --- drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c index 210d84c67ef9..f2298330e05b 100644 --- a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c +++ b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c @@ -226,7 +226,7 @@ int t7xx_dpmaif_rx_buf_alloc(struct dpmaif_ctrl *dpmaif_ctrl, return 0; err_unmap_skbs: - while (--i > 0) + while (--i >= 0) t7xx_unmap_bat_skb(dpmaif_ctrl->dev, bat_req->bat_skb, i); return ret;