+ linux-wireless
Julia Lawall <[email protected]> writes:
> The ifs starting on line 766 can fail because id is NULL.
>
> julia
>
> ---------- Forwarded message ----------
> Date: Fri, 26 Apr 2019 06:39:46 +0800
> From: kbuild test robot <[email protected]>
> To: [email protected]
> Cc: Julia Lawall <[email protected]>
> Subject: [wireless-drivers-next:master 21/45]
> drivers/net/wireless/rsi/rsi_91x_usb.c:774:17-26: ERROR: id is NULL but
> dereferenced.
>
> CC: [email protected]
> TO: Siva Rebbagondla <[email protected]>
> CC: Kalle Valo <[email protected]>
>
> tree:
> https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git
> master
> head: 147b502bda338f4f2dff19faaa5829b691305ea5
> commit: 54fdb318c1116814711fad4bd166e6c85a477ef0 [21/45] rsi: add new
> device model for 9116
> :::::: branch date: 5 hours ago
> :::::: commit date: 6 hours ago
>
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <[email protected]>
> Reported-by: Julia Lawall <[email protected]>
>
>>> drivers/net/wireless/rsi/rsi_91x_usb.c:774:17-26: ERROR: id is NULL
> but dereferenced.
>
> #
> https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git/commit/?id=54fdb318c1116814711fad4bd166e6c85a477ef0
> git remote add wireless-drivers-next
> https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git
> git remote update wireless-drivers-next
> git checkout 54fdb318c1116814711fad4bd166e6c85a477ef0
> vim +774 drivers/net/wireless/rsi/rsi_91x_usb.c
>
> ea0676c47 Karun Eagalapati 2017-07-06 729
> dad0d04fa Fariya Fatima 2014-03-16 730 /**
> dad0d04fa Fariya Fatima 2014-03-16 731 * rsi_probe() - This function
> is called by kernel when the driver provided
> dad0d04fa Fariya Fatima 2014-03-16 732 * Vendor and device IDs are
> matched. All the initialization
> dad0d04fa Fariya Fatima 2014-03-16 733 * work is done here.
> dad0d04fa Fariya Fatima 2014-03-16 734 * @pfunction: Pointer to the
> USB interface structure.
> dad0d04fa Fariya Fatima 2014-03-16 735 * @id: Pointer to the
> usb_device_id structure.
> dad0d04fa Fariya Fatima 2014-03-16 736 *
> 50591c60a Alexey Khoroshilov 2014-06-27 737 * Return: 0 on success, a
> negative error code on failure.
> dad0d04fa Fariya Fatima 2014-03-16 738 */
> dad0d04fa Fariya Fatima 2014-03-16 739 static int rsi_probe(struct
> usb_interface *pfunction,
> dad0d04fa Fariya Fatima 2014-03-16 740 const struct usb_device_id *id)
> dad0d04fa Fariya Fatima 2014-03-16 741 {
> dad0d04fa Fariya Fatima 2014-03-16 742 struct rsi_hw *adapter;
> dad0d04fa Fariya Fatima 2014-03-16 743 struct rsi_91x_usbdev *dev;
> dad0d04fa Fariya Fatima 2014-03-16 744 u16 fw_status;
> 50591c60a Alexey Khoroshilov 2014-06-27 745 int status;
> dad0d04fa Fariya Fatima 2014-03-16 746
> dad0d04fa Fariya Fatima 2014-03-16 747 rsi_dbg(INIT_ZONE, "%s: Init
> function called\n", __func__);
> dad0d04fa Fariya Fatima 2014-03-16 748
> 898b25533 Prameela Rani Garnepudi 2018-02-27 749 adapter =
> rsi_91x_init(dev_oper_mode);
> dad0d04fa Fariya Fatima 2014-03-16 750 if (!adapter) {
> dad0d04fa Fariya Fatima 2014-03-16 751 rsi_dbg(ERR_ZONE, "%s: Failed
> to init os intf ops\n",
> dad0d04fa Fariya Fatima 2014-03-16 752 __func__);
> 50591c60a Alexey Khoroshilov 2014-06-27 753 return -ENOMEM;
> dad0d04fa Fariya Fatima 2014-03-16 754 }
> b78e91bcf Prameela Rani Garnepudi 2017-05-16 755
> adapter->rsi_host_intf = RSI_HOST_INTF_USB;
> dad0d04fa Fariya Fatima 2014-03-16 756
> 50591c60a Alexey Khoroshilov 2014-06-27 757 status =
> rsi_init_usb_interface(adapter, pfunction);
> 50591c60a Alexey Khoroshilov 2014-06-27 758 if (status) {
> dad0d04fa Fariya Fatima 2014-03-16 759 rsi_dbg(ERR_ZONE, "%s: Failed
> to init usb interface\n",
> dad0d04fa Fariya Fatima 2014-03-16 760 __func__);
> dad0d04fa Fariya Fatima 2014-03-16 761 goto err;
> dad0d04fa Fariya Fatima 2014-03-16 762 }
> dad0d04fa Fariya Fatima 2014-03-16 763
> dad0d04fa Fariya Fatima 2014-03-16 764 rsi_dbg(ERR_ZONE, "%s:
> Initialized os intf ops\n", __func__);
> dad0d04fa Fariya Fatima 2014-03-16 765
> 54fdb318c Siva Rebbagondla 2019-04-03 766 if (id && id->idProduct ==
> RSI_USB_PID_9113) {
> 54fdb318c Siva Rebbagondla 2019-04-03 767 rsi_dbg(INIT_ZONE, "%s: 9113
> module detected\n", __func__);
> 54fdb318c Siva Rebbagondla 2019-04-03 768 adapter->device_model =
> RSI_DEV_9113;
> 54fdb318c Siva Rebbagondla 2019-04-03 769 } else if (id &&
> id->idProduct == RSI_USB_PID_9116) {
> 54fdb318c Siva Rebbagondla 2019-04-03 770 rsi_dbg(INIT_ZONE, "%s: 9116
> module detected\n", __func__);
> 54fdb318c Siva Rebbagondla 2019-04-03 771 adapter->device_model =
> RSI_DEV_9116;
> 54fdb318c Siva Rebbagondla 2019-04-03 772 } else {
> 54fdb318c Siva Rebbagondla 2019-04-03 773 rsi_dbg(ERR_ZONE, "%s:
> Unsupported RSI device id 0x%x\n",
> 54fdb318c Siva Rebbagondla 2019-04-03 @774 __func__, id->idProduct);
> 54fdb318c Siva Rebbagondla 2019-04-03 775 goto err1;
> 54fdb318c Siva Rebbagondla 2019-04-03 776 }
> 54fdb318c Siva Rebbagondla 2019-04-03 777
> dad0d04fa Fariya Fatima 2014-03-16 778 dev = (struct rsi_91x_usbdev
> *)adapter->rsi_dev;
> dad0d04fa Fariya Fatima 2014-03-16 779
> 50591c60a Alexey Khoroshilov 2014-06-27 780 status =
> rsi_usb_reg_read(dev->usbdev, FW_STATUS_REG, &fw_status, 2);
> b78e91bcf Prameela Rani Garnepudi 2017-05-16 781 if (status < 0)
> dad0d04fa Fariya Fatima 2014-03-16 782 goto err1;
> dad0d04fa Fariya Fatima 2014-03-16 783 else
> dad0d04fa Fariya Fatima 2014-03-16 784 fw_status &= 1;
> dad0d04fa Fariya Fatima 2014-03-16 785
> dad0d04fa Fariya Fatima 2014-03-16 786 if (!fw_status) {
> b78e91bcf Prameela Rani Garnepudi 2017-05-16 787 rsi_dbg(INIT_ZONE,
> "Loading firmware...\n");
> b78e91bcf Prameela Rani Garnepudi 2017-05-16 788 status =
> rsi_hal_device_init(adapter);
> 50591c60a Alexey Khoroshilov 2014-06-27 789 if (status) {
> dad0d04fa Fariya Fatima 2014-03-16 790 rsi_dbg(ERR_ZONE, "%s: Failed
> in device init\n",
> dad0d04fa Fariya Fatima 2014-03-16 791 __func__);
> dad0d04fa Fariya Fatima 2014-03-16 792 goto err1;
> dad0d04fa Fariya Fatima 2014-03-16 793 }
> b78e91bcf Prameela Rani Garnepudi 2017-05-16 794 rsi_dbg(INIT_ZONE,
> "%s: Device Init Done\n", __func__);
> dad0d04fa Fariya Fatima 2014-03-16 795 }
> dad0d04fa Fariya Fatima 2014-03-16 796
> 1100f81bb Prameela Rani Garnepudi 2018-02-27 797 status =
> rsi_rx_urb_submit(adapter, WLAN_EP);
> 50591c60a Alexey Khoroshilov 2014-06-27 798 if (status)
> dad0d04fa Fariya Fatima 2014-03-16 799 goto err1;
> dad0d04fa Fariya Fatima 2014-03-16 800
> a4302bff2 Siva Rebbagondla 2018-02-27 801 if (adapter->priv->coex_mode
>> 1) {
> a4302bff2 Siva Rebbagondla 2018-02-27 802 status =
> rsi_rx_urb_submit(adapter, BT_EP);
> a4302bff2 Siva Rebbagondla 2018-02-27 803 if (status)
> a4302bff2 Siva Rebbagondla 2018-02-27 804 goto err1;
> a4302bff2 Siva Rebbagondla 2018-02-27 805 }
> a4302bff2 Siva Rebbagondla 2018-02-27 806
> dad0d04fa Fariya Fatima 2014-03-16 807 return 0;
> dad0d04fa Fariya Fatima 2014-03-16 808 err1:
> dad0d04fa Fariya Fatima 2014-03-16 809
> rsi_deinit_usb_interface(adapter);
> dad0d04fa Fariya Fatima 2014-03-16 810 err:
> dad0d04fa Fariya Fatima 2014-03-16 811 rsi_91x_deinit(adapter);
> dad0d04fa Fariya Fatima 2014-03-16 812 rsi_dbg(ERR_ZONE, "%s: Failed
> in probe...Exiting\n", __func__);
> 50591c60a Alexey Khoroshilov 2014-06-27 813 return status;
> dad0d04fa Fariya Fatima 2014-03-16 814 }
> dad0d04fa Fariya Fatima 2014-03-16 815
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
--
Kalle Valo
Hi,
On Fri, Apr 26, 2019 at 8:28 PM Kalle Valo <[email protected]> wrote:
>
> + linux-wireless
>
> Julia Lawall <[email protected]> writes:
>
> > The ifs starting on line 766 can fail because id is NULL.
I don't think id will be NULL here. id is coming from probe.
Is there any other opinions?.
> >
> > julia
> >
> > ---------- Forwarded message ----------
> > Date: Fri, 26 Apr 2019 06:39:46 +0800
> > From: kbuild test robot <[email protected]>
> > To: [email protected]
> > Cc: Julia Lawall <[email protected]>
> > Subject: [wireless-drivers-next:master 21/45]
> > drivers/net/wireless/rsi/rsi_91x_usb.c:774:17-26: ERROR: id is NULL but
> > dereferenced.
> >
> > CC: [email protected]
> > TO: Siva Rebbagondla <[email protected]>
> > CC: Kalle Valo <[email protected]>
> >
> > tree:
> > https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git
> > master
> > head: 147b502bda338f4f2dff19faaa5829b691305ea5
> > commit: 54fdb318c1116814711fad4bd166e6c85a477ef0 [21/45] rsi: add new
> > device model for 9116
> > :::::: branch date: 5 hours ago
> > :::::: commit date: 6 hours ago
> >
> > If you fix the issue, kindly add following tag
> > Reported-by: kbuild test robot <[email protected]>
> > Reported-by: Julia Lawall <[email protected]>
> >
> >>> drivers/net/wireless/rsi/rsi_91x_usb.c:774:17-26: ERROR: id is NULL
> > but dereferenced.
> >
> > #
> > https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git/commit/?id=54fdb318c1116814711fad4bd166e6c85a477ef0
> > git remote add wireless-drivers-next
> > https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git
> > git remote update wireless-drivers-next
> > git checkout 54fdb318c1116814711fad4bd166e6c85a477ef0
> > vim +774 drivers/net/wireless/rsi/rsi_91x_usb.c
> >
> > ea0676c47 Karun Eagalapati 2017-07-06 729
> > dad0d04fa Fariya Fatima 2014-03-16 730 /**
> > dad0d04fa Fariya Fatima 2014-03-16 731 * rsi_probe() - This function
> > is called by kernel when the driver provided
> > dad0d04fa Fariya Fatima 2014-03-16 732 * Vendor and device IDs are
> > matched. All the initialization
> > dad0d04fa Fariya Fatima 2014-03-16 733 * work is done here.
> > dad0d04fa Fariya Fatima 2014-03-16 734 * @pfunction: Pointer to the
> > USB interface structure.
> > dad0d04fa Fariya Fatima 2014-03-16 735 * @id: Pointer to the
> > usb_device_id structure.
> > dad0d04fa Fariya Fatima 2014-03-16 736 *
> > 50591c60a Alexey Khoroshilov 2014-06-27 737 * Return: 0 on success, a
> > negative error code on failure.
> > dad0d04fa Fariya Fatima 2014-03-16 738 */
> > dad0d04fa Fariya Fatima 2014-03-16 739 static int rsi_probe(struct
> > usb_interface *pfunction,
> > dad0d04fa Fariya Fatima 2014-03-16 740 const struct usb_device_id *id)
> > dad0d04fa Fariya Fatima 2014-03-16 741 {
> > dad0d04fa Fariya Fatima 2014-03-16 742 struct rsi_hw *adapter;
> > dad0d04fa Fariya Fatima 2014-03-16 743 struct rsi_91x_usbdev *dev;
> > dad0d04fa Fariya Fatima 2014-03-16 744 u16 fw_status;
> > 50591c60a Alexey Khoroshilov 2014-06-27 745 int status;
> > dad0d04fa Fariya Fatima 2014-03-16 746
> > dad0d04fa Fariya Fatima 2014-03-16 747 rsi_dbg(INIT_ZONE, "%s: Init
> > function called\n", __func__);
> > dad0d04fa Fariya Fatima 2014-03-16 748
> > 898b25533 Prameela Rani Garnepudi 2018-02-27 749 adapter =
> > rsi_91x_init(dev_oper_mode);
> > dad0d04fa Fariya Fatima 2014-03-16 750 if (!adapter) {
> > dad0d04fa Fariya Fatima 2014-03-16 751 rsi_dbg(ERR_ZONE, "%s: Failed
> > to init os intf ops\n",
> > dad0d04fa Fariya Fatima 2014-03-16 752 __func__);
> > 50591c60a Alexey Khoroshilov 2014-06-27 753 return -ENOMEM;
> > dad0d04fa Fariya Fatima 2014-03-16 754 }
> > b78e91bcf Prameela Rani Garnepudi 2017-05-16 755
> > adapter->rsi_host_intf = RSI_HOST_INTF_USB;
> > dad0d04fa Fariya Fatima 2014-03-16 756
> > 50591c60a Alexey Khoroshilov 2014-06-27 757 status =
> > rsi_init_usb_interface(adapter, pfunction);
> > 50591c60a Alexey Khoroshilov 2014-06-27 758 if (status) {
> > dad0d04fa Fariya Fatima 2014-03-16 759 rsi_dbg(ERR_ZONE, "%s: Failed
> > to init usb interface\n",
> > dad0d04fa Fariya Fatima 2014-03-16 760 __func__);
> > dad0d04fa Fariya Fatima 2014-03-16 761 goto err;
> > dad0d04fa Fariya Fatima 2014-03-16 762 }
> > dad0d04fa Fariya Fatima 2014-03-16 763
> > dad0d04fa Fariya Fatima 2014-03-16 764 rsi_dbg(ERR_ZONE, "%s:
> > Initialized os intf ops\n", __func__);
> > dad0d04fa Fariya Fatima 2014-03-16 765
> > 54fdb318c Siva Rebbagondla 2019-04-03 766 if (id && id->idProduct ==
> > RSI_USB_PID_9113) {
> > 54fdb318c Siva Rebbagondla 2019-04-03 767 rsi_dbg(INIT_ZONE, "%s: 9113
> > module detected\n", __func__);
> > 54fdb318c Siva Rebbagondla 2019-04-03 768 adapter->device_model =
> > RSI_DEV_9113;
> > 54fdb318c Siva Rebbagondla 2019-04-03 769 } else if (id &&
> > id->idProduct == RSI_USB_PID_9116) {
> > 54fdb318c Siva Rebbagondla 2019-04-03 770 rsi_dbg(INIT_ZONE, "%s: 9116
> > module detected\n", __func__);
> > 54fdb318c Siva Rebbagondla 2019-04-03 771 adapter->device_model =
> > RSI_DEV_9116;
> > 54fdb318c Siva Rebbagondla 2019-04-03 772 } else {
> > 54fdb318c Siva Rebbagondla 2019-04-03 773 rsi_dbg(ERR_ZONE, "%s:
> > Unsupported RSI device id 0x%x\n",
> > 54fdb318c Siva Rebbagondla 2019-04-03 @774 __func__, id->idProduct);
> > 54fdb318c Siva Rebbagondla 2019-04-03 775 goto err1;
> > 54fdb318c Siva Rebbagondla 2019-04-03 776 }
> > 54fdb318c Siva Rebbagondla 2019-04-03 777
> > dad0d04fa Fariya Fatima 2014-03-16 778 dev = (struct rsi_91x_usbdev
> > *)adapter->rsi_dev;
> > dad0d04fa Fariya Fatima 2014-03-16 779
> > 50591c60a Alexey Khoroshilov 2014-06-27 780 status =
> > rsi_usb_reg_read(dev->usbdev, FW_STATUS_REG, &fw_status, 2);
> > b78e91bcf Prameela Rani Garnepudi 2017-05-16 781 if (status < 0)
> > dad0d04fa Fariya Fatima 2014-03-16 782 goto err1;
> > dad0d04fa Fariya Fatima 2014-03-16 783 else
> > dad0d04fa Fariya Fatima 2014-03-16 784 fw_status &= 1;
> > dad0d04fa Fariya Fatima 2014-03-16 785
> > dad0d04fa Fariya Fatima 2014-03-16 786 if (!fw_status) {
> > b78e91bcf Prameela Rani Garnepudi 2017-05-16 787 rsi_dbg(INIT_ZONE,
> > "Loading firmware...\n");
> > b78e91bcf Prameela Rani Garnepudi 2017-05-16 788 status =
> > rsi_hal_device_init(adapter);
> > 50591c60a Alexey Khoroshilov 2014-06-27 789 if (status) {
> > dad0d04fa Fariya Fatima 2014-03-16 790 rsi_dbg(ERR_ZONE, "%s: Failed
> > in device init\n",
> > dad0d04fa Fariya Fatima 2014-03-16 791 __func__);
> > dad0d04fa Fariya Fatima 2014-03-16 792 goto err1;
> > dad0d04fa Fariya Fatima 2014-03-16 793 }
> > b78e91bcf Prameela Rani Garnepudi 2017-05-16 794 rsi_dbg(INIT_ZONE,
> > "%s: Device Init Done\n", __func__);
> > dad0d04fa Fariya Fatima 2014-03-16 795 }
> > dad0d04fa Fariya Fatima 2014-03-16 796
> > 1100f81bb Prameela Rani Garnepudi 2018-02-27 797 status =
> > rsi_rx_urb_submit(adapter, WLAN_EP);
> > 50591c60a Alexey Khoroshilov 2014-06-27 798 if (status)
> > dad0d04fa Fariya Fatima 2014-03-16 799 goto err1;
> > dad0d04fa Fariya Fatima 2014-03-16 800
> > a4302bff2 Siva Rebbagondla 2018-02-27 801 if (adapter->priv->coex_mode
> >> 1) {
> > a4302bff2 Siva Rebbagondla 2018-02-27 802 status =
> > rsi_rx_urb_submit(adapter, BT_EP);
> > a4302bff2 Siva Rebbagondla 2018-02-27 803 if (status)
> > a4302bff2 Siva Rebbagondla 2018-02-27 804 goto err1;
> > a4302bff2 Siva Rebbagondla 2018-02-27 805 }
> > a4302bff2 Siva Rebbagondla 2018-02-27 806
> > dad0d04fa Fariya Fatima 2014-03-16 807 return 0;
> > dad0d04fa Fariya Fatima 2014-03-16 808 err1:
> > dad0d04fa Fariya Fatima 2014-03-16 809
> > rsi_deinit_usb_interface(adapter);
> > dad0d04fa Fariya Fatima 2014-03-16 810 err:
> > dad0d04fa Fariya Fatima 2014-03-16 811 rsi_91x_deinit(adapter);
> > dad0d04fa Fariya Fatima 2014-03-16 812 rsi_dbg(ERR_ZONE, "%s: Failed
> > in probe...Exiting\n", __func__);
> > 50591c60a Alexey Khoroshilov 2014-06-27 813 return status;
> > dad0d04fa Fariya Fatima 2014-03-16 814 }
> > dad0d04fa Fariya Fatima 2014-03-16 815
> >
> > ---
> > 0-DAY kernel test infrastructure Open Source Technology Center
> > https://lists.01.org/pipermail/kbuild-all Intel Corporation
>
> --
> Kalle Valo
--
Siva Rebbagondla
Siva Rebbagondla <[email protected]> writes:
> On Fri, Apr 26, 2019 at 8:28 PM Kalle Valo <[email protected]> wrote:
>
>> Julia Lawall <[email protected]> writes:
>>
>> > The ifs starting on line 766 can fail because id is NULL.
>
> I don't think id will be NULL here. id is coming from probe.
> Is there any other opinions?.
The code in question:
if (id && id->idProduct == RSI_USB_PID_9113) {
rsi_dbg(INIT_ZONE, "%s: 9113 module detected\n", __func__);
adapter->device_model = RSI_DEV_9113;
} else if (id && id->idProduct == RSI_USB_PID_9116) {
rsi_dbg(INIT_ZONE, "%s: 9116 module detected\n", __func__);
adapter->device_model = RSI_DEV_9116;
} else {
rsi_dbg(ERR_ZONE, "%s: Unsupported RSI device id 0x%x\n",
__func__, id->idProduct);
goto err1;
}
I think the fact that you are checking if id is NULL is confusing the
static checkers. If it's never NULL why check for that anyway? So if
it's guaranteed that id is never NULL (I didn't check that from USB
core) I would recommend to remove the NULL checks from the driver.
--
Kalle Valo
Hi kalle,
On Fri, Apr 26, 2019 at 8:55 PM Kalle Valo <[email protected]> wrote:
>
> Siva Rebbagondla <[email protected]> writes:
>
> > On Fri, Apr 26, 2019 at 8:28 PM Kalle Valo <[email protected]> wrote:
> >
> >> Julia Lawall <[email protected]> writes:
> >>
> >> > The ifs starting on line 766 can fail because id is NULL.
> >
> > I don't think id will be NULL here. id is coming from probe.
> > Is there any other opinions?.
>
> The code in question:
>
> if (id && id->idProduct == RSI_USB_PID_9113) {
> rsi_dbg(INIT_ZONE, "%s: 9113 module detected\n", __func__);
> adapter->device_model = RSI_DEV_9113;
> } else if (id && id->idProduct == RSI_USB_PID_9116) {
> rsi_dbg(INIT_ZONE, "%s: 9116 module detected\n", __func__);
> adapter->device_model = RSI_DEV_9116;
> } else {
> rsi_dbg(ERR_ZONE, "%s: Unsupported RSI device id 0x%x\n",
> __func__, id->idProduct);
> goto err1;
> }
>
> I think the fact that you are checking if id is NULL is confusing the
> static checkers. If it's never NULL why check for that anyway? So if
> it's guaranteed that id is never NULL (I didn't check that from USB
> core) I would recommend to remove the NULL checks from the driver.
Yes Kalle. I agree. I will make the change and send you for the review.
---
Siva Rebbagondla