Linux kernel staging patches
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Nihar Chaithanya <niharchaithanya@gmail.com>,
	dpenkler@gmail.com, gregkh@linuxfoundation.org
Cc: dan.carpenter@linaro.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v4 01/15] staging: gpib: Modify gpib_register_driver() to return error if it fails
Date: Thu, 26 Dec 2024 13:41:02 -0700	[thread overview]
Message-ID: <e659e77d-9c09-436a-b5a2-bf9fe28f644c@linuxfoundation.org> (raw)
In-Reply-To: <20241226193637.241049-2-niharchaithanya@gmail.com>

On 12/26/24 12:36, Nihar Chaithanya wrote:
> The function gpib_register_driver() can fail if kmalloc() fails,
> but it doesn't return any error if that happens.
> 
> Modify the function to return error i.e int. Return the appropriate
> error code if it fails.
> 
> Signed-off-by: Nihar Chaithanya <niharchaithanya@gmail.com>
> ---
>   drivers/staging/gpib/common/gpib_os.c | 7 ++++---
>   drivers/staging/gpib/include/gpibP.h  | 2 +-
>   2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/gpib/common/gpib_os.c b/drivers/staging/gpib/common/gpib_os.c
> index 405237d8cb47..07795df3b721 100644
> --- a/drivers/staging/gpib/common/gpib_os.c
> +++ b/drivers/staging/gpib/common/gpib_os.c
> @@ -2094,18 +2094,19 @@ void init_gpib_descriptor(gpib_descriptor_t *desc)
>   	atomic_set(&desc->io_in_progress, 0);
>   }
>   
> -void gpib_register_driver(gpib_interface_t *interface, struct module *provider_module)
> +int gpib_register_driver(gpib_interface_t *interface, struct module *provider_module)
>   {
>   	struct gpib_interface_list_struct *entry;
>   
>   	entry = kmalloc(sizeof(*entry), GFP_KERNEL);
>   	if (!entry)
> -		return;
> +		return -ENOMEM;
>   
>   	entry->interface = interface;
>   	entry->module = provider_module;
>   	list_add(&entry->list, &registered_drivers);
> -	pr_info("gpib: registered %s interface\n", interface->name);

Did you mean to delete this message? - looks like an useful message.
Could you make this dev_info() instead?

> +
> +	return 0;
>   }
>   EXPORT_SYMBOL(gpib_register_driver);
>   
> diff --git a/drivers/staging/gpib/include/gpibP.h b/drivers/staging/gpib/include/gpibP.h
> index 5fc42b645ab7..d0cd42c1a0ad 100644
> --- a/drivers/staging/gpib/include/gpibP.h
> +++ b/drivers/staging/gpib/include/gpibP.h
> @@ -17,7 +17,7 @@
>   #include <linux/fs.h>
>   #include <linux/interrupt.h>
>   
> -void gpib_register_driver(gpib_interface_t *interface, struct module *mod);
> +int gpib_register_driver(gpib_interface_t *interface, struct module *mod);
>   void gpib_unregister_driver(gpib_interface_t *interface);
>   struct pci_dev *gpib_pci_get_device(const gpib_board_config_t *config, unsigned int vendor_id,
>   				    unsigned int device_id, struct pci_dev *from);

thanks,
-- Shuah

  reply	other threads:[~2024-12-26 20:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-26 19:36 [PATCH v4 00/15] staging: gpib: Handle gpib_register_driver() errors Nihar Chaithanya
2024-12-26 19:36 ` [PATCH v4 01/15] staging: gpib: Modify gpib_register_driver() to return error if it fails Nihar Chaithanya
2024-12-26 20:41   ` Shuah Khan [this message]
2024-12-27 12:19     ` Nihar Chaithanya
2024-12-26 19:36 ` [PATCH v4 02/15] staging: gpib: agilent_82350b: Handle gpib_register_driver() errors Nihar Chaithanya
2024-12-26 20:43   ` Shuah Khan
2024-12-26 19:36 ` [PATCH v4 03/15] staging: gpib: agilent_82357a: " Nihar Chaithanya
2024-12-26 21:10   ` Shuah Khan
2024-12-26 19:36 ` [PATCH v4 04/15] staging: gpib: cb7210: " Nihar Chaithanya
2024-12-26 19:36 ` [PATCH v4 05/15] staging: gpib: cec: " Nihar Chaithanya
2024-12-26 19:36 ` [PATCH v4 06/15] staging: gpib: fluke: " Nihar Chaithanya
2024-12-26 19:36 ` [PATCH v4 07/15] staging: gpib: fmh: " Nihar Chaithanya
2024-12-26 23:32   ` kernel test robot
2024-12-27  2:51   ` kernel test robot
2024-12-26 19:36 ` [PATCH v4 08/15] staging: gpib: gpio: Return error value from gpib_register_driver() Nihar Chaithanya
2024-12-26 19:36 ` [PATCH v4 09/15] staging: gpib: hp_82335: " Nihar Chaithanya
2024-12-26 19:36 ` [PATCH v4 10/15] staging: gpib: hp_82341: Handle gpib_register_driver() errors Nihar Chaithanya
2024-12-26 19:36 ` [PATCH v4 11/15] staging: gpib: ines: " Nihar Chaithanya
2024-12-26 19:36 ` [PATCH v4 12/15] staging: gpib: lpvo_usb: Return error value from gpib_register_driver() Nihar Chaithanya
2024-12-26 19:36 ` [PATCH v4 13/15] staging: gpib: ni_usb: Handle gpib_register_driver() errors Nihar Chaithanya
2024-12-26 19:36 ` [PATCH v4 14/15] staging: gpib: pc2: " Nihar Chaithanya
2024-12-26 19:36 ` [PATCH v4 15/15] staging: gpib: tnt4882: " Nihar Chaithanya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e659e77d-9c09-436a-b5a2-bf9fe28f644c@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=dan.carpenter@linaro.org \
    --cc=dpenkler@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=niharchaithanya@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox