net: ipa: fix atomic update in ipa_endpoint_replenish()
authorAlex Elder <elder@linaro.org>
Wed, 12 Jan 2022 13:30:10 +0000 (07:30 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 5 Feb 2022 11:37:55 +0000 (12:37 +0100)
commit2ed912e3e057b2e883cade4dcf9be74fcc5a7e82
treed9bd2b55fefc5eda546fd64e88f746a238c72583
parent3b4c966fb156ff3e70b2526d964952ff7c1574d9
net: ipa: fix atomic update in ipa_endpoint_replenish()

commit 6c0e3b5ce94947b311348c367db9e11dcb2ccc93 upstream.

In ipa_endpoint_replenish(), if an error occurs when attempting to
replenish a receive buffer, we just quit and try again later.  In
that case we increment the backlog count to reflect that the attempt
was unsuccessful.  Then, if the add_one flag was true we increment
the backlog again.

This second increment is not included in the backlog local variable
though, and its value determines whether delayed work should be
scheduled.  This is a bug.

Fix this by determining whether 1 or 2 should be added to the
backlog before adding it in a atomic_add_return() call.

Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Fixes: 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints")
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ipa/ipa_endpoint.c