greybus: don't let i2c code assume non-null payload pointer
authorAlex Elder <elder@linaro.org>
Wed, 3 Dec 2014 18:27:43 +0000 (12:27 -0600)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 3 Dec 2014 23:08:17 +0000 (15:08 -0800)
commit7a9366aa1e8645c12c0050b417358089c216d14f
treea39139746df4dc5efb8027dc751f5aaacc694b08
parent93bbe859b75616ebdc33722c3b30cf36e74161a8
greybus: don't let i2c code assume non-null payload pointer

This is in preparation for an upcoming patch, which makes the
payload pointer be NULL when a message has zero bytes of payload.

It ensures a null payload pointer never gets dereferenced.  To do
this we pass the response structure to gb_i2c_transfer_response()
rather than just its data, and if it's null, returning immediately.

Rearrange the logic in gb_i2c_transfer_operation() a bit.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/i2c-gb.c