From: Corey Minyard <minyard@acm.org>
To: Joeseph Chang <joechang@qti.qualcomm.com>,
openipmi-developer@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Cc: anjiandi@qti.qualcomm.com, Joeseph Chang <joechang@codeaurora.org>
Subject: Re: [PATCH] ipmi: Fix kernel panic at ipmi_ssif_thread()
Date: Fri, 24 Mar 2017 21:53:16 -0500 [thread overview]
Message-ID: <6d686ff9-e94b-ddc0-cf9f-13a839acbb08@acm.org> (raw)
In-Reply-To: <1490252832-20381-1-git-send-email-joechang@qti.qualcomm.com>
This is incorrect. These values *must* be set before ssif_i2c_send() is
done.
Once ssif_i2c_send() is called, msg_written_handler can be called at any
time after that, including before where you moved the new code.
If I understand this correctly, I think you need to add a variable,
maybe named "bytes_to_write" and do
bytes_to_write = ssif_info->multi_data + ssif_info->multi_pos;
before the comparison and pass bytes_to_write into
ssif_i2c_send().
Thanks,
-corey
On 03/23/2017 02:07 AM, Joeseph Chang wrote:
> From: Joeseph Chang <joechang@codeaurora.org>
>
> msg_written_handler() may set ssif_info->multi_data to NULL
> when using ipmitool to write fru.
> Change the ssif i2c send data sequence in msg_written_handler()
> to fix NULL pointer kernel panic and incorrect ssif_info->multi_pos.
>
> Signed-off-by: Joeseph Chang <joechang@codeaurora.org>
> ---
> drivers/char/ipmi/ipmi_ssif.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
> index cca6e5b..39346ee 100644
> --- a/drivers/char/ipmi/ipmi_ssif.c
> +++ b/drivers/char/ipmi/ipmi_ssif.c
> @@ -899,21 +899,13 @@ static void msg_written_handler(struct ssif_info *ssif_info, int result,
> left = 32;
> /* Length byte. */
> ssif_info->multi_data[ssif_info->multi_pos] = left;
> - ssif_info->multi_pos += left;
> - if (left < 32)
> - /*
> - * Write is finished. Note that we must end
> - * with a write of less than 32 bytes to
> - * complete the transaction, even if it is
> - * zero bytes.
> - */
> - ssif_info->multi_data = NULL;
>
> rv = ssif_i2c_send(ssif_info, msg_written_handler,
> I2C_SMBUS_WRITE,
> SSIF_IPMI_MULTI_PART_REQUEST_MIDDLE,
> ssif_info->multi_data + ssif_info->multi_pos,
> I2C_SMBUS_BLOCK_DATA);
> +
> if (rv < 0) {
> /* request failed, just return the error. */
> ssif_inc_stat(ssif_info, send_errors);
> @@ -922,6 +914,16 @@ static void msg_written_handler(struct ssif_info *ssif_info, int result,
> pr_info("Error from i2c_non_blocking_op(3)\n");
> msg_done_handler(ssif_info, -EIO, NULL, 0);
> }
> +
> + ssif_info->multi_pos += left;
> + if (left < 32)
> + /*
> + * Write is finished. Note that we must end
> + * with a write of less than 32 bytes to
> + * complete the transaction, even if it is
> + * zero bytes.
> + */
> + ssif_info->multi_data = NULL;
> } else {
> /* Ready to request the result. */
> unsigned long oflags, *flags;
next prev parent reply other threads:[~2017-03-25 2:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-23 7:07 Joeseph Chang
2017-03-25 2:53 ` Corey Minyard [this message]
2017-03-27 3:02 ` Joseph Chang
2017-03-27 5:04 ` joechang
2017-03-28 2:22 Joeseph Chang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6d686ff9-e94b-ddc0-cf9f-13a839acbb08@acm.org \
--to=minyard@acm.org \
--cc=anjiandi@qti.qualcomm.com \
--cc=joechang@codeaurora.org \
--cc=joechang@qti.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=openipmi-developer@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome