Message ID | 20231207-tps6598x_update-v2-3-f3cfcde6d890@wolfvision.net (mailing list archive) |
---|---|
State | Accepted |
Commit | e79ead88eeb8f3e945355b537bfaca7532dfee10 |
Headers | show |
Series | usb: typec: tipd: add patch update support for tps6598x | expand |
On Thu, Dec 14, 2023 at 05:29:11PM +0100, Javier Carrasco wrote: > The input data passed to execute commands with tps6598x_exec_cmd() > is not supposed to be modified by the function. Moreover, this data is > passed to tps6598x_exec_cmd_tmo() and finally to tps6598x_block_write(), > which expects a const pointer. > > The current implementation does not produce any bugs, but it discards > const qualifiers from the pointers passed as arguments. This leads to > compile issues if 'discarded-qualifiers' is active and a const pointer > is passed to the function, which is the case if data from a firmware > structure is passed to execute update commands. Adding the const > modifier to in_data prevents such issues and provides code consistency. > > Signed-off-by: Javier Carrasco <javier.carrasco@wolfvision.net> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > --- > drivers/usb/typec/tipd/core.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > index 83e5eeecdf5c..7f4bbc0629b0 100644 > --- a/drivers/usb/typec/tipd/core.c > +++ b/drivers/usb/typec/tipd/core.c > @@ -330,7 +330,7 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 status) > } > > static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, > - size_t in_len, u8 *in_data, > + size_t in_len, const u8 *in_data, > size_t out_len, u8 *out_data, > u32 cmd_timeout_ms, u32 res_delay_ms) > { > @@ -396,7 +396,7 @@ static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, > } > > static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, > - size_t in_len, u8 *in_data, > + size_t in_len, const u8 *in_data, > size_t out_len, u8 *out_data) > { > return tps6598x_exec_cmd_tmo(tps, cmd, in_len, in_data, > > -- > 2.39.2
diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 83e5eeecdf5c..7f4bbc0629b0 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -330,7 +330,7 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 status) } static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, - size_t in_len, u8 *in_data, + size_t in_len, const u8 *in_data, size_t out_len, u8 *out_data, u32 cmd_timeout_ms, u32 res_delay_ms) { @@ -396,7 +396,7 @@ static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, } static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, - size_t in_len, u8 *in_data, + size_t in_len, const u8 *in_data, size_t out_len, u8 *out_data) { return tps6598x_exec_cmd_tmo(tps, cmd, in_len, in_data,
The input data passed to execute commands with tps6598x_exec_cmd() is not supposed to be modified by the function. Moreover, this data is passed to tps6598x_exec_cmd_tmo() and finally to tps6598x_block_write(), which expects a const pointer. The current implementation does not produce any bugs, but it discards const qualifiers from the pointers passed as arguments. This leads to compile issues if 'discarded-qualifiers' is active and a const pointer is passed to the function, which is the case if data from a firmware structure is passed to execute update commands. Adding the const modifier to in_data prevents such issues and provides code consistency. Signed-off-by: Javier Carrasco <javier.carrasco@wolfvision.net> --- drivers/usb/typec/tipd/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)