From: Johannes Berg Date: Tue, 21 Jan 2014 20:19:18 +0000 (+0100) Subject: iwlwifi: pcie: make FH debugfs file code easier to understand X-Git-Tag: firefly_0821_release~176^2~4167^2~18^2^2~371^2~61 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=56c2477f23c3bb3aa33516301b3eab0efe05bbe1;p=firefly-linux-kernel-4.4.55.git iwlwifi: pcie: make FH debugfs file code easier to understand The code seems fine, as buf won't be assigned when an error is returned, but checking for the error first is easier to understand. Signed-off-by: Johannes Berg Signed-off-by: Emmanuel Grumbach --- diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c index 7290f422be65..61ae1af34f17 100644 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c @@ -1434,16 +1434,15 @@ static ssize_t iwl_dbgfs_fh_reg_read(struct file *file, { struct iwl_trans *trans = file->private_data; char *buf = NULL; - int pos = 0; - ssize_t ret = -EFAULT; - - ret = pos = iwl_dump_fh(trans, &buf); - if (buf) { - ret = simple_read_from_buffer(user_buf, - count, ppos, buf, pos); - kfree(buf); - } + ssize_t ret; + ret = iwl_dump_fh(trans, &buf); + if (ret < 0) + return ret; + if (!buf) + return -EINVAL; + ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); + kfree(buf); return ret; }