From 59399c2471461658cf450870846a2b7e2f4e5661 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 7 Mar 2014 04:02:39 +0000 Subject: [PATCH] PERSISTENT RESERVE IN: Suppress a kernel warning for small output buffer sizes This patch suppresses the following error message and kernel warning: scst: ***ERROR***: Too big response data len 24 (max 8), limiting it to the max (dev iis) Call Trace: [] ? dump_stack+0x41/0x56 [] ? scst_set_resp_data_len+0x82/0xb1 [scst] [] ? scst_pr_read_reservation+0xbf/0xc4 [scst] [] ? scst_persistent_reserve_in_local+0x140/0x1ce [scst] [] ? scst_exec_check_blocking+0x57/0xf1 [scst] [] ? scst_process_active_cmd+0x86c/0x136f [scst] [] ? scst_do_job_active+0x45/0x5b [scst] [] ? scst_cmd_thread+0x218/0x2b7 [scst] [] ? wake_up_bit+0x23/0x23 [] ? scst_cmd_tasklet+0x32/0x32 [scst] [] ? kthread_freezable_should_stop+0x51/0x51 [] ? scst_cmd_tasklet+0x32/0x32 [scst] [] ? kthread+0xab/0xb3 [] ? kthread_freezable_should_stop+0x51/0x51 [] ? ret_from_fork+0x7c/0xb0 [] ? kthread_freezable_should_stop+0x51/0x51 Reported-by: Roman Bogdanov Signed-off-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5324 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_pres.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index e7210d433..5ab3b6eb1 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -2457,7 +2457,7 @@ void scst_pr_read_reservation(struct scst_cmd *cmd, uint8_t *buffer, if (buffer_size < 8) { TRACE_PR("buffer_size too small: %d. expected >= 8 " "(buffer %p)", buffer_size, buffer); - goto skip; + goto out; } memset(b, 0, sizeof(b)); @@ -2491,10 +2491,10 @@ void scst_pr_read_reservation(struct scst_cmd *cmd, uint8_t *buffer, size = 24; } - memset(buffer, 0, buffer_size); - memcpy(buffer, b, min(size, buffer_size)); - -skip: +out: + size = min(size, buffer_size); + memcpy(buffer, b, size); + memset(buffer + size, 0, buffer_size - size); scst_set_resp_data_len(cmd, size); TRACE_EXIT();