From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756298AbdKCTuQ (ORCPT ); Fri, 3 Nov 2017 15:50:16 -0400 Received: from mout.web.de ([212.227.15.14]:63458 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754684AbdKCTuO (ORCPT ); Fri, 3 Nov 2017 15:50:14 -0400 To: devel@driverdev.osuosl.org, sparmaintainer@unisys.com, Bryan Thompson , David Binder , David Kershner , Greg Kroah-Hartman , Sameer Wadgaonkar , Tim Sell From: SF Markus Elfring Subject: [PATCH] staging: unisys: visorchipset: Use common error handling code in setup_crash_devices_work_queue() Cc: LKML , kernel-janitors@vger.kernel.org Message-ID: Date: Fri, 3 Nov 2017 20:50:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:eS2/KJdJK1XLu7pwZ9dmj+4M5l4JxOxkhYkM8h1zj7zjuH2x3a5 8mg2YiOoIwuQWfep4EPGyY1Ou6EBmb9dErNP8vNdonZkFoa0XNuct1lapVjmhtnuGG5eEN3 Mz7wyNMAZ/c5eP787EFhJ3OFLesMleH+CvyzXb2BmtqccMaq0OReO+utAgXVPSI1O9f6uPg gE50cEg0LXBrEMNKDBhMw== X-UI-Out-Filterresults: notjunk:1;V01:K0:cAIbCCRjC90=:hPwZirwd3OSl+M/i3O8PPH HKOjh7cii5wXSnFrphvoJvwohQqeAHNwZ0c5uGm97m5Zi6g6n1AAYUw99/FcpdZhU6kYtnfLd d1CkOUOHi143/GbDivu+TWBA+hdVBi5VT1Gyy7Xchyp0VNcT1f+i5uvbzFJgaF2q3Kz4bkoDh pLaXTVanpDQiKQbAPHMAiZlAu15ZfI1kmM2D7HwBtH342ten8psdrXNiB0JFSgVpI3YptZT9r AmTaWTaRQPE9ZU/+e11Owjt9YUBmxLQCSmgH9QqX0qoDDcfw0/7+W0MFrFU9G6cYXmrOHOjIY x6y1Yt5L4MUpQGTkkmI2eW7iKgHcRGWP4jQURImZVGo1CQKIXM+e60bCRl/GjObS0MpZCvnSk zz7KCW4vWTlj9jTz8a9rnf7homRwozLnH97dzXbF1DSvvMKvtfxExfJsaMhgo3/09wwoODitc apcVKCanFNhYwbnZxpXNjX9FGWTxJ2KdQr5YGo9hVO7qROSmqJesK491+vXIK6BdIo9gev4by noVGM1R/Hbd/qe81Mvv53UMf+HS39e/JLXPyzqvCgoiI8lCVkR6R9HAXGLcBTyRdBzYkPkDze mSA94Jtq8GYw3Jtdlg+Uk1KMLDoYHMv/fzNrXK8xhSxgn83PQJJqbuizU8QSxYuE4QpTHwfYp sWhwaeR8QS1v2oiV5CC1lPsFeU59NwrmBRC3sJAtrNyitIleF9OrysRDGJe8ZHwqd/V6btxzA S/myabbls15JKmVKEsVZoN/a+d0yNeYkbqu+VFBUFAgnt3f70ancTQvFrytR0I8tILCZHV97y IsmpYJu3j3QSV2Q6S9pMQXItJFbV8ZD7ROEQI5UysrmignPz0w= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Fri, 3 Nov 2017 20:37:03 +0100 * Add a jump target so that a specific error message is stored only once at the end of this function implementation. * Replace four calls of the function "dev_err" by goto statements. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/staging/unisys/visorbus/visorchipset.c | 36 ++++++++++++-------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index fed554a43151..1d54821dd7b6 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -1231,11 +1231,9 @@ static void setup_crash_devices_work_queue(struct work_struct *work) if (visorchannel_read(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, saved_crash_message_count), - &local_crash_msg_count, sizeof(u16)) < 0) { - dev_err(&chipset_dev->acpi_device->dev, - "failed to read channel\n"); - return; - } + &local_crash_msg_count, sizeof(u16)) < 0) + goto report_read_failure; + if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) { dev_err(&chipset_dev->acpi_device->dev, "invalid count\n"); return; @@ -1244,30 +1242,24 @@ static void setup_crash_devices_work_queue(struct work_struct *work) if (visorchannel_read(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, saved_crash_message_offset), - &local_crash_msg_offset, sizeof(u32)) < 0) { - dev_err(&chipset_dev->acpi_device->dev, - "failed to read channel\n"); - return; - } + &local_crash_msg_offset, sizeof(u32)) < 0) + goto report_read_failure; + /* read create device message for storage bus offset */ if (visorchannel_read(chipset_dev->controlvm_channel, local_crash_msg_offset, &local_crash_bus_msg, - sizeof(struct controlvm_message)) < 0) { - dev_err(&chipset_dev->acpi_device->dev, - "failed to read channel\n"); - return; - } + sizeof(struct controlvm_message)) < 0) + goto report_read_failure; + /* read create device message for storage device */ if (visorchannel_read(chipset_dev->controlvm_channel, local_crash_msg_offset + sizeof(struct controlvm_message), &local_crash_dev_msg, - sizeof(struct controlvm_message)) < 0) { - dev_err(&chipset_dev->acpi_device->dev, - "failed to read channel\n"); - return; - } + sizeof(struct controlvm_message)) < 0) + goto report_read_failure; + /* reuse IOVM create bus message */ if (!local_crash_bus_msg.cmd.create_bus.channel_addr) { dev_err(&chipset_dev->acpi_device->dev, @@ -1282,6 +1274,10 @@ static void setup_crash_devices_work_queue(struct work_struct *work) return; } visorbus_device_create(&local_crash_dev_msg); + return; + +report_read_failure: + dev_err(&chipset_dev->acpi_device->dev, "failed to read channel\n"); } void visorbus_response(struct visor_device *bus_info, int response, -- 2.15.0