From patchwork Mon Dec 2 13:49:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Yushchenko X-Patchwork-Id: 13890699 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 495A5202F65 for ; Mon, 2 Dec 2024 13:49:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733147371; cv=none; b=mfh2qmaMlDZoJ7h6gpcDTkGLmIfBc5Uggscr/R+1qZNZyDSZ3j30h6tNAcqcBoK0mETIXYLwdIRIKVR3tO9iZUTPdJUIYkVfVr/aiC6m7Q8PW59nYGYLRz6ZqKFagBOrZ25U6kvcvWO2QviL5B6DPJTlbQwQep0b4a8nrz75tro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733147371; c=relaxed/simple; bh=ikLggKYh0Un8afUAvMUCGvNq/h+HGVzb6q6YC7Oxa3A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cgEjSZLsxt17mv6+aGyfUETE/YHg0CePOJdawcfcv+mhMhx6AXZxEXUJqk4yUUaJMwD4iD/+cXpqyOB3QxHOOu9KZ5ft493qOyqRI0LVaDqgWvL+tJivC9bHZ1m8fB+dQHm6gJ0sRlw/BDF21PH2Rxv+T30uLo0G9717trnrTjE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cogentembedded.com; spf=pass smtp.mailfrom=cogentembedded.com; dkim=pass (2048-bit key) header.d=cogentembedded-com.20230601.gappssmtp.com header.i=@cogentembedded-com.20230601.gappssmtp.com header.b=Hq3T9o5Z; arc=none smtp.client-ip=209.85.208.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cogentembedded.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cogentembedded.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cogentembedded-com.20230601.gappssmtp.com header.i=@cogentembedded-com.20230601.gappssmtp.com header.b="Hq3T9o5Z" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2ffe2700e91so35117151fa.2 for ; Mon, 02 Dec 2024 05:49:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20230601.gappssmtp.com; s=20230601; t=1733147368; x=1733752168; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P4PkmDMX0LCsciSdEuZzJRFJdqj1nfUT/bpDSGbr0kc=; b=Hq3T9o5ZO8J/XNIYur/Mmrju6aQ+W7TP1s6nkkl+uuMQYSvzGImfNbnr4pyur+Z7TB 2Tfacnc3UObebZLIykraVC8fROTkMBbk0WxpSPlXDF9vqggZx/NAYHXGijxWQf2mfFqB y51TLTKjsOUUdln0rF453qR0OU9A82yjTuH2MbmHIujPOZ5Os9YPDT/7TIZSNs7uhXrl GQyRg0zfdONLZNjWMiO+wNAl51t23mFnZ8K6Onj1Ixhx1p/nK00fYGi10hgCOZoGtFWF AyuqD5Whz1QqtORL+i/dNpZY4bEMA+pAm5qVckSJn7RNiyIpcoNDp6Js4cInKNajIGOx b9mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733147368; x=1733752168; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P4PkmDMX0LCsciSdEuZzJRFJdqj1nfUT/bpDSGbr0kc=; b=M4V+olIoJizlqHXRXTm+SKgKJ9n9S2tKU4NWzk7PuszSTQTRqxya6C6U1F3nkYFJWD duKzoAw5SNnVzOl9eOnf2Jy3ZyPD9cvwWzu1ZKjUl6m0UcQfZTkdc8k4apKhRWrBWnQ/ f/Q+F7uKJ4r8D2MDf6ehJ/MlMhheB4jbAevuWqIgkVysKJaM9ekNi8/+0hM5RnONQGCZ Ixes1Og+wu3Cpua6OvR4Iw8wRvph5AkCWvtBPHiCgXJzAZFP7izcpdCWMBUDgIxXqTtk +TT4pUEuarA5xekpKsPEGoI4e1Qn/av4eeSF08udFweCLj01H4ygSAkXliaKJQS9O+Di C2ow== X-Gm-Message-State: AOJu0YwrydRLoNBGRCXOOA71/VamQgVS7Bas2a1uRE4wbkDB0ggfjskN 3LJENn4j8RCi5nk0wwrZUq8Ziqz3fzOTdPL1P033eJvxSfcByTBJ/pJoJQqLXP4= X-Gm-Gg: ASbGncsgb8Ojg+K9Y9fQMj6qEzm3RLRNAfGA5BZthdirBi5+5WPlOcW5JjTuvL3bzgx GofpdS4eVLVGToTDVDoTtpQrgP6yyrCZqtLV+5maI2Gy1V+3JQkCwKTBO8aGJxt7N11JuQrHzio KxGdcvXjIB2r/fhteoii7/oL0IE3SXaaqApU0q1W1zzpb+6Xowhh9gr0DVbx5BzzCf5ZwfJyvY6 X9zinYQA0n64ii19P2X48knSjeaIT1QHAbNn/XO44Xzh0lUEM/BPXU3+zQihtlO X-Google-Smtp-Source: AGHT+IEsaH+gdxnFkWmsXqpHCD1Zei6m+iH0fYiLGHgbg3pVjQplVpLyAye27YVe8QxL4WzDTSyj7w== X-Received: by 2002:a05:651c:2207:b0:2ff:566e:b583 with SMTP id 38308e7fff4ca-2ffd5fff0cemr104563321fa.11.1733147368492; Mon, 02 Dec 2024 05:49:28 -0800 (PST) Received: from cobook.home ([91.198.101.25]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ffdfbb8f2csm12972661fa.15.2024.12.02.05.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 05:49:28 -0800 (PST) From: Nikita Yushchenko To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Geert Uytterhoeven Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege , Christian Mardmoeller , Dennis Ostermann , Nikita Yushchenko Subject: [PATCH 2/5] net: renesas: rswitch: fix leaked pointer on error path Date: Mon, 2 Dec 2024 18:49:01 +0500 Message-Id: <20241202134904.3882317-3-nikita.yoush@cogentembedded.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241202134904.3882317-1-nikita.yoush@cogentembedded.com> References: <20241202134904.3882317-1-nikita.yoush@cogentembedded.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org If error path is taken while filling descriptor for a frame, skb pointer is left in the entry. Later, on the ring entry reuse, the same entry could be used as a part of a multi-descriptor frame, and skb for that new frame could be stored in a different entry. Then, the stale pointer will reach the completion routine, and passed to the release operation. Fix that by clearing the saved skb pointer at the error path. Fixes: d2c96b9d5f83 ("net: rswitch: Add jumbo frames handling for TX") Signed-off-by: Nikita Yushchenko Reviewed-by: Jacob Keller --- drivers/net/ethernet/renesas/rswitch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index 32b32aa7e01f..3ad5858d3cdd 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1703,6 +1703,7 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd return ret; err_unmap: + gq->skbs[(gq->cur + nr_desc - 1) % gq->ring_size] = NULL; dma_unmap_single(ndev->dev.parent, dma_addr_orig, skb->len, DMA_TO_DEVICE); err_kfree: