Skip to content

Commit 6b80ea3

Browse files
Gilad Ben-Yossefherbertx
authored andcommitted
crypto: change transient busy return code to -ENOSPC
The crypto API was using the -EBUSY return value to indicate both a hard failure to submit a crypto operation into a transformation provider when the latter was busy and the backlog mechanism was not enabled as well as a notification that the operation was queued into the backlog when the backlog mechanism was enabled. Having the same return code indicate two very different conditions depending on a flag is both error prone and requires extra runtime check like the following to discern between the cases: if (err == -EINPROGRESS || (err == -EBUSY && (ahash_request_flags(req) & CRYPTO_TFM_REQ_MAY_BACKLOG))) This patch changes the return code used to indicate a crypto op failed due to the transformation provider being transiently busy to -ENOSPC. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent c8dd5e4 commit 6b80ea3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

crypto/algapi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,9 +897,11 @@ int crypto_enqueue_request(struct crypto_queue *queue,
897897
int err = -EINPROGRESS;
898898

899899
if (unlikely(queue->qlen >= queue->max_qlen)) {
900-
err = -EBUSY;
901-
if (!(request->flags & CRYPTO_TFM_REQ_MAY_BACKLOG))
900+
if (!(request->flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) {
901+
err = -ENOSPC;
902902
goto out;
903+
}
904+
err = -EBUSY;
903905
if (queue->backlog == &queue->list)
904906
queue->backlog = &request->list;
905907
}

crypto/cryptd.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,14 @@ static int cryptd_enqueue_request(struct cryptd_queue *queue,
137137
int cpu, err;
138138
struct cryptd_cpu_queue *cpu_queue;
139139
atomic_t *refcnt;
140-
bool may_backlog;
141140

142141
cpu = get_cpu();
143142
cpu_queue = this_cpu_ptr(queue->cpu_queue);
144143
err = crypto_enqueue_request(&cpu_queue->queue, request);
145144

146145
refcnt = crypto_tfm_ctx(request->tfm);
147-
may_backlog = request->flags & CRYPTO_TFM_REQ_MAY_BACKLOG;
148146

149-
if (err == -EBUSY && !may_backlog)
147+
if (err == -ENOSPC)
150148
goto out_put_cpu;
151149

152150
queue_work_on(cpu, kcrypto_wq, &cpu_queue->work);

0 commit comments

Comments
 (0)