All of lore.kernel.org
 help / color / mirror / Atom feed
* [wens:mtk-wip 24/48] drivers/gpu/drm/bridge/analogix/anx7625.c:2658 anx7625_typec_mux_set() error: 'port' dereferencing possible ERR_PTR()
@ 2025-01-17 20:16 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-01-17 20:16 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: "Pin-yen Lin" <treapking@chromium.org>
CC: "Chen-Yu Tsai" <wenst@chromium.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/wens/linux.git mtk-wip
head:   a2f8143f6e1e6b3d8dac24f675646fbfdfc03202
commit: d62036e150e84eff425756d90cf8f060d86beb17 [24/48] drm/bridge: anx7625: Register Type C mode switches
:::::: branch date: 4 days ago
:::::: commit date: 4 days ago
config: arm-randconfig-r071-20250117 (https://download.01.org/0day-ci/archive/20250118/202501180409.LUg1bFSN-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 14.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202501180409.LUg1bFSN-lkp@intel.com/

smatch warnings:
drivers/gpu/drm/bridge/analogix/anx7625.c:2658 anx7625_typec_mux_set() error: 'port' dereferencing possible ERR_PTR()

vim +/port +2658 drivers/gpu/drm/bridge/analogix/anx7625.c

d62036e150e84e Pin-yen Lin 2023-03-31  2653  
d62036e150e84e Pin-yen Lin 2023-03-31  2654  static int anx7625_typec_mux_set(struct typec_mux_dev *mux,
d62036e150e84e Pin-yen Lin 2023-03-31  2655  				 struct typec_mux_state *state)
d62036e150e84e Pin-yen Lin 2023-03-31  2656  {
d62036e150e84e Pin-yen Lin 2023-03-31  2657  	struct drm_dp_typec_port_data *port = typec_mux_get_drvdata(mux);
d62036e150e84e Pin-yen Lin 2023-03-31 @2658  	struct anx7625_data *ctx = port->data;
d62036e150e84e Pin-yen Lin 2023-03-31  2659  	struct device *dev = ctx->dev;
d62036e150e84e Pin-yen Lin 2023-03-31  2660  	struct drm_dp_typec_switch_desc switch_desc = ctx->switch_desc;
d62036e150e84e Pin-yen Lin 2023-03-31  2661  	bool new_dp_connected, old_dp_connected;
d62036e150e84e Pin-yen Lin 2023-03-31  2662  
d62036e150e84e Pin-yen Lin 2023-03-31  2663  	if (switch_desc.num_typec_switches == 1)
d62036e150e84e Pin-yen Lin 2023-03-31  2664  		return 0;
d62036e150e84e Pin-yen Lin 2023-03-31  2665  
d62036e150e84e Pin-yen Lin 2023-03-31  2666  	/*
d62036e150e84e Pin-yen Lin 2023-03-31  2667  	 * The completion is called in anx7625_register_typec_switches
d62036e150e84e Pin-yen Lin 2023-03-31  2668  	 * even on errors, so it's safe to wait for completion without timeout.
d62036e150e84e Pin-yen Lin 2023-03-31  2669  	 */
d62036e150e84e Pin-yen Lin 2023-03-31  2670  	wait_for_completion(&ctx->mux_register);
d62036e150e84e Pin-yen Lin 2023-03-31  2671  
d62036e150e84e Pin-yen Lin 2023-03-31  2672  	/* Abort when the switches are unregistered. */
d62036e150e84e Pin-yen Lin 2023-03-31  2673  	if (!ctx->port_data)
d62036e150e84e Pin-yen Lin 2023-03-31  2674  		return -EINVAL;
d62036e150e84e Pin-yen Lin 2023-03-31  2675  
d62036e150e84e Pin-yen Lin 2023-03-31  2676  	old_dp_connected = ctx->port_data[0].dp_connected ||
d62036e150e84e Pin-yen Lin 2023-03-31  2677  			   ctx->port_data[1].dp_connected;
d62036e150e84e Pin-yen Lin 2023-03-31  2678  
d62036e150e84e Pin-yen Lin 2023-03-31  2679  	ctx->port_data[port->port_num].dp_connected =
d62036e150e84e Pin-yen Lin 2023-03-31  2680  		state->alt &&
d62036e150e84e Pin-yen Lin 2023-03-31  2681  		state->alt->svid == USB_TYPEC_DP_SID &&
d62036e150e84e Pin-yen Lin 2023-03-31  2682  		state->alt->mode == USB_TYPEC_DP_MODE;
d62036e150e84e Pin-yen Lin 2023-03-31  2683  
d62036e150e84e Pin-yen Lin 2023-03-31  2684  	dev_dbg(dev, "mux_set dp_connected: c0=%d, c1=%d\n",
d62036e150e84e Pin-yen Lin 2023-03-31  2685  		ctx->port_data[0].dp_connected, ctx->port_data[1].dp_connected);
d62036e150e84e Pin-yen Lin 2023-03-31  2686  
d62036e150e84e Pin-yen Lin 2023-03-31  2687  	new_dp_connected = ctx->port_data[0].dp_connected ||
d62036e150e84e Pin-yen Lin 2023-03-31  2688  			   ctx->port_data[1].dp_connected;
d62036e150e84e Pin-yen Lin 2023-03-31  2689  
d62036e150e84e Pin-yen Lin 2023-03-31  2690  	/* DP on, power on first */
d62036e150e84e Pin-yen Lin 2023-03-31  2691  	if (!old_dp_connected && new_dp_connected)
d62036e150e84e Pin-yen Lin 2023-03-31  2692  		pm_runtime_get_sync(dev);
d62036e150e84e Pin-yen Lin 2023-03-31  2693  
d62036e150e84e Pin-yen Lin 2023-03-31  2694  	anx7625_typec_two_ports_update(ctx);
d62036e150e84e Pin-yen Lin 2023-03-31  2695  
d62036e150e84e Pin-yen Lin 2023-03-31  2696  	/* DP off, power off last */
d62036e150e84e Pin-yen Lin 2023-03-31  2697  	if (old_dp_connected && !new_dp_connected)
d62036e150e84e Pin-yen Lin 2023-03-31  2698  		pm_runtime_put_sync(dev);
d62036e150e84e Pin-yen Lin 2023-03-31  2699  
d62036e150e84e Pin-yen Lin 2023-03-31  2700  	return 0;
d62036e150e84e Pin-yen Lin 2023-03-31  2701  }
d62036e150e84e Pin-yen Lin 2023-03-31  2702  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [wens:mtk-wip 24/48] drivers/gpu/drm/bridge/analogix/anx7625.c:2658 anx7625_typec_mux_set() error: 'port' dereferencing possible ERR_PTR()
@ 2025-01-20  5:36 Dan Carpenter
  2025-01-20  9:17 ` Pin-yen Lin
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2025-01-20  5:36 UTC (permalink / raw)
  To: oe-kbuild, Pin-yen Lin; +Cc: lkp, oe-kbuild-all, Chen-Yu Tsai

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/wens/linux.git mtk-wip
head:   a2f8143f6e1e6b3d8dac24f675646fbfdfc03202
commit: d62036e150e84eff425756d90cf8f060d86beb17 [24/48] drm/bridge: anx7625: Register Type C mode switches
config: arm-randconfig-r071-20250117 (https://download.01.org/0day-ci/archive/20250118/202501180409.LUg1bFSN-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 14.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202501180409.LUg1bFSN-lkp@intel.com/

smatch warnings:
drivers/gpu/drm/bridge/analogix/anx7625.c:2658 anx7625_typec_mux_set() error: 'port' dereferencing possible ERR_PTR()

vim +/port +2658 drivers/gpu/drm/bridge/analogix/anx7625.c

d62036e150e84e Pin-yen Lin 2023-03-31  2654  static int anx7625_typec_mux_set(struct typec_mux_dev *mux,
d62036e150e84e Pin-yen Lin 2023-03-31  2655  				 struct typec_mux_state *state)
d62036e150e84e Pin-yen Lin 2023-03-31  2656  {
d62036e150e84e Pin-yen Lin 2023-03-31  2657  	struct drm_dp_typec_port_data *port = typec_mux_get_drvdata(mux);
                                                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
typec_mux_get_drvdata() this returns ERR_PTR(-EOPNOTSUPP) if CONFIG_TYPEC
is disabled.  I assumed that the Kconfig specified that CONFIG_TYPEC had
to be enabled unless COMPILE_TEST was enabled but I didn't find that in
the KConfig when I looked.

Does the Kconfig have a depend/select/imply on CONFIG_TYPEC that I missed?

d62036e150e84e Pin-yen Lin 2023-03-31 @2658  	struct anx7625_data *ctx = port->data;
d62036e150e84e Pin-yen Lin 2023-03-31  2659  	struct device *dev = ctx->dev;
d62036e150e84e Pin-yen Lin 2023-03-31  2660  	struct drm_dp_typec_switch_desc switch_desc = ctx->switch_desc;
d62036e150e84e Pin-yen Lin 2023-03-31  2661  	bool new_dp_connected, old_dp_connected;
d62036e150e84e Pin-yen Lin 2023-03-31  2662  
d62036e150e84e Pin-yen Lin 2023-03-31  2663  	if (switch_desc.num_typec_switches == 1)
d62036e150e84e Pin-yen Lin 2023-03-31  2664  		return 0;

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [wens:mtk-wip 24/48] drivers/gpu/drm/bridge/analogix/anx7625.c:2658 anx7625_typec_mux_set() error: 'port' dereferencing possible ERR_PTR()
  2025-01-20  5:36 Dan Carpenter
@ 2025-01-20  9:17 ` Pin-yen Lin
  2025-01-20 10:17   ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Pin-yen Lin @ 2025-01-20  9:17 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: oe-kbuild, lkp, oe-kbuild-all, Chen-Yu Tsai

Hi Dan,

On Mon, Jan 20, 2025 at 1:36 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/wens/linux.git mtk-wip
> head:   a2f8143f6e1e6b3d8dac24f675646fbfdfc03202
> commit: d62036e150e84eff425756d90cf8f060d86beb17 [24/48] drm/bridge: anx7625: Register Type C mode switches
> config: arm-randconfig-r071-20250117 (https://download.01.org/0day-ci/archive/20250118/202501180409.LUg1bFSN-lkp@intel.com/config)
> compiler: arm-linux-gnueabi-gcc (GCC) 14.2.0
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> | Closes: https://lore.kernel.org/r/202501180409.LUg1bFSN-lkp@intel.com/
>
> smatch warnings:
> drivers/gpu/drm/bridge/analogix/anx7625.c:2658 anx7625_typec_mux_set() error: 'port' dereferencing possible ERR_PTR()
>
> vim +/port +2658 drivers/gpu/drm/bridge/analogix/anx7625.c
>
> d62036e150e84e Pin-yen Lin 2023-03-31  2654  static int anx7625_typec_mux_set(struct typec_mux_dev *mux,
> d62036e150e84e Pin-yen Lin 2023-03-31  2655                              struct typec_mux_state *state)
> d62036e150e84e Pin-yen Lin 2023-03-31  2656  {
> d62036e150e84e Pin-yen Lin 2023-03-31  2657     struct drm_dp_typec_port_data *port = typec_mux_get_drvdata(mux);
>                                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
> typec_mux_get_drvdata() this returns ERR_PTR(-EOPNOTSUPP) if CONFIG_TYPEC
> is disabled.  I assumed that the Kconfig specified that CONFIG_TYPEC had
> to be enabled unless COMPILE_TEST was enabled but I didn't find that in
> the KConfig when I looked.

This is a callback that is only registered through
`typec_mux_register()`, which also returns ERR_PTR(-EOPNOTSUPP) when
CONFIG_TYPEC is disabled.

So, anx7625_typec_mux_set() should never be called when CONFIG_TYPEC
is disabled.
>
> Does the Kconfig have a depend/select/imply on CONFIG_TYPEC that I missed?

The Kconfig around this is "depends on TYPEC || TYPEC=n", though this
is not directly related to the warning here.

>
> d62036e150e84e Pin-yen Lin 2023-03-31 @2658     struct anx7625_data *ctx = port->data;
> d62036e150e84e Pin-yen Lin 2023-03-31  2659     struct device *dev = ctx->dev;
> d62036e150e84e Pin-yen Lin 2023-03-31  2660     struct drm_dp_typec_switch_desc switch_desc = ctx->switch_desc;
> d62036e150e84e Pin-yen Lin 2023-03-31  2661     bool new_dp_connected, old_dp_connected;
> d62036e150e84e Pin-yen Lin 2023-03-31  2662
> d62036e150e84e Pin-yen Lin 2023-03-31  2663     if (switch_desc.num_typec_switches == 1)
> d62036e150e84e Pin-yen Lin 2023-03-31  2664             return 0;
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
>

Regards,
Pin-yen

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [wens:mtk-wip 24/48] drivers/gpu/drm/bridge/analogix/anx7625.c:2658 anx7625_typec_mux_set() error: 'port' dereferencing possible ERR_PTR()
  2025-01-20  9:17 ` Pin-yen Lin
@ 2025-01-20 10:17   ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-01-20 10:17 UTC (permalink / raw)
  To: Pin-yen Lin; +Cc: oe-kbuild, lkp, oe-kbuild-all, Chen-Yu Tsai

On Mon, Jan 20, 2025 at 05:17:41PM +0800, Pin-yen Lin wrote:
> Hi Dan,
> 
> On Mon, Jan 20, 2025 at 1:36 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/wens/linux.git mtk-wip
> > head:   a2f8143f6e1e6b3d8dac24f675646fbfdfc03202
> > commit: d62036e150e84eff425756d90cf8f060d86beb17 [24/48] drm/bridge: anx7625: Register Type C mode switches
> > config: arm-randconfig-r071-20250117 (https://download.01.org/0day-ci/archive/20250118/202501180409.LUg1bFSN-lkp@intel.com/config)
> > compiler: arm-linux-gnueabi-gcc (GCC) 14.2.0
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> > | Closes: https://lore.kernel.org/r/202501180409.LUg1bFSN-lkp@intel.com/
> >
> > smatch warnings:
> > drivers/gpu/drm/bridge/analogix/anx7625.c:2658 anx7625_typec_mux_set() error: 'port' dereferencing possible ERR_PTR()
> >
> > vim +/port +2658 drivers/gpu/drm/bridge/analogix/anx7625.c
> >
> > d62036e150e84e Pin-yen Lin 2023-03-31  2654  static int anx7625_typec_mux_set(struct typec_mux_dev *mux,
> > d62036e150e84e Pin-yen Lin 2023-03-31  2655                              struct typec_mux_state *state)
> > d62036e150e84e Pin-yen Lin 2023-03-31  2656  {
> > d62036e150e84e Pin-yen Lin 2023-03-31  2657     struct drm_dp_typec_port_data *port = typec_mux_get_drvdata(mux);
> >                                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
> > typec_mux_get_drvdata() this returns ERR_PTR(-EOPNOTSUPP) if CONFIG_TYPEC
> > is disabled.  I assumed that the Kconfig specified that CONFIG_TYPEC had
> > to be enabled unless COMPILE_TEST was enabled but I didn't find that in
> > the KConfig when I looked.
> 
> This is a callback that is only registered through
> `typec_mux_register()`, which also returns ERR_PTR(-EOPNOTSUPP) when
> CONFIG_TYPEC is disabled.
> 
> So, anx7625_typec_mux_set() should never be called when CONFIG_TYPEC
> is disabled.
> >
> > Does the Kconfig have a depend/select/imply on CONFIG_TYPEC that I missed?
> 
> The Kconfig around this is "depends on TYPEC || TYPEC=n", though this
> is not directly related to the warning here.
> 

Ah thanks...

drivers/gpu/drm/bridge/analogix/anx7625.c
  2902          /* Add work function */
  2903          if (platform->pdata.intp_irq)
  2904                  queue_work(platform->workqueue, &platform->work);
  2905  
  2906          ret = anx7625_register_typec_switches(dev, platform);
  2907          if (ret && ret != -ENODEV)
  2908                  dev_warn(dev, "Didn't register Type-C switches, err: %d\n", ret);

If TYPEC is disabled then anx7625_register_typec_switches() will return
-EOPNOTSUPP.  We normally would not print this dev_warn() if the feature
was disabled deliberately.  To be honest, we would normally return NULL
when a feature is disabled deliberately but it's probably too late to fix
that...

  2909  
  2910          if (platform->pdata.audio_en)
  2911                  anx7625_register_audio(dev, platform);

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-20 10:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-17 20:16 [wens:mtk-wip 24/48] drivers/gpu/drm/bridge/analogix/anx7625.c:2658 anx7625_typec_mux_set() error: 'port' dereferencing possible ERR_PTR() kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2025-01-20  5:36 Dan Carpenter
2025-01-20  9:17 ` Pin-yen Lin
2025-01-20 10:17   ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.