[PATCH 1/1]drm/gma500: mdfld: Remove unncessary code
On Wed, Jun 24, 2015 at 10:54 AM, Maninder Singh wrote: > Hi, > >>> - if (!sender || !data_out || !len_out) { >>> - DRM_ERROR("Invalid parameters\n"); >>> - return -EINVAL; >>> - } >>> - >> >>I would prefer to have these kind of checks where it actually matters >>(ie. in __read_panel_data()). The saner thing would be to move the >>dereference until after the check and remove the duplicated check from >>mdfld_dsi_read_mcs(). That would prevent any further need for adding >>additional checks whenever calling __read_panel_data(). > > Ok agree, But i am thinking whether this initilaization has to be there? > struct drm_device *dev = sender->dev; > > Because in function __read_panel_data I saw no usage of this dev struct, > So along with check from mdfld_dsi_read_mcs, can we remove this dev from > __read_panel_data also ? Or i missed something in code? REG_READ and REG_WRITE macros need the drm device (see psb_drv.h) so it must stay. > Thanks, > Maninder > -
[PATCH 1/1]drm/gma500: mdfld: Remove unncessary code
sender is dereferrenced before NULL check struct drm_device *dev = sender->dev; and due to this we get warning during static analysis: warn: variable dereferenced before check 'sender' __read_panel_data Function is called by mdfld_dsi_read_mcs and there is a same check, Thus removing the check from __read_panel_data. Signed-off-by: Maninder Singh Reviewed-by: Vaneet Narang --- drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c |5 - 1 files changed, 0 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c index 6b43ae3..d29b881 100644 --- a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c +++ b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c @@ -525,11 +525,6 @@ static int __read_panel_data(struct mdfld_dsi_pkg_sender *sender, u8 data_type, u32 gen_data_reg; int retry = MDFLD_DSI_READ_MAX_COUNT; - if (!sender || !data_out || !len_out) { - DRM_ERROR("Invalid parameters\n"); - return -EINVAL; - } - /** * do reading. * 0) send out generic read request -- 1.7.1
[PATCH 1/1]drm/gma500: mdfld: Remove unncessary code
On Wed, Jun 24, 2015 at 9:10 AM, Maninder Singh wrote: > sender is dereferrenced before NULL check > struct drm_device *dev = sender->dev; > > and due to this we get warning during static analysis: > warn: variable dereferenced before check 'sender' > > __read_panel_data Function is called by mdfld_dsi_read_mcs > and there is a same check, Thus removing the check from > __read_panel_data. > > Signed-off-by: Maninder Singh > Reviewed-by: Vaneet Narang > --- > drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c |5 - > 1 files changed, 0 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c > b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c > index 6b43ae3..d29b881 100644 > --- a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c > +++ b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c > @@ -525,11 +525,6 @@ static int __read_panel_data(struct mdfld_dsi_pkg_sender > *sender, u8 data_type, > u32 gen_data_reg; > int retry = MDFLD_DSI_READ_MAX_COUNT; > > - if (!sender || !data_out || !len_out) { > - DRM_ERROR("Invalid parameters\n"); > - return -EINVAL; > - } > - I would prefer to have these kind of checks where it actually matters (ie. in __read_panel_data()). The saner thing would be to move the dereference until after the check and remove the duplicated check from mdfld_dsi_read_mcs(). That would prevent any further need for adding additional checks whenever calling __read_panel_data(). Cheers Patrik > /** > * do reading. > * 0) send out generic read request > -- > 1.7.1 > ___ > dri-devel mailing list > dri-devel at lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 1/1]drm/gma500: mdfld: Remove unncessary code
Hi, >> - if (!sender || !data_out || !len_out) { >> - DRM_ERROR("Invalid parameters\n"); >> - return -EINVAL; >> - } >> - > >I would prefer to have these kind of checks where it actually matters >(ie. in __read_panel_data()). The saner thing would be to move the >dereference until after the check and remove the duplicated check from >mdfld_dsi_read_mcs(). That would prevent any further need for adding >additional checks whenever calling __read_panel_data(). Ok agree, But i am thinking whether this initilaization has to be there? struct drm_device *dev = sender->dev; Because in function __read_panel_data I saw no usage of this dev struct, So along with check from mdfld_dsi_read_mcs, can we remove this dev from __read_panel_data also ? Or i missed something in code? Thanks, Maninder -