From: Aditya Pakki <pakki001@umn.edu> To: pakki001@umn.edu Cc: kjlu@umn.edu, Alan Stern <stern@rowland.harvard.edu>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org Subject: [PATCH] USB: storage: Fix potential NULL pointer derefernce Date: Wed, 13 Mar 2019 12:48:58 -0500 [thread overview] Message-ID: <20190313174858.23859-1-pakki001@umn.edu> (raw) Allocating memory via kcalloc for pba_to_lba and lba_to_pba can fail. The fix avoids a potential NULL pointer dereference. Signed-off-by: Aditya Pakki <pakki001@umn.edu> --- drivers/usb/storage/alauda.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index 6b8edf6178df..41d979e70784 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c @@ -438,6 +438,11 @@ static int alauda_init_media(struct us_data *us) MEDIA_INFO(us).pba_to_lba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO); MEDIA_INFO(us).lba_to_pba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO); + if (!MEDIA_INFO(us).pba_to_lba || !MEDIA_INFO(us).lba_to_pba) { + pr_warn("%s: Failed to allocate memory\n", __func__); + return USB_STOR_TRANSPORT_ERROR; + } + if (alauda_reset_media(us) != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; -- 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Aditya Pakki <pakki001@umn.edu> To: pakki001@umn.edu Cc: kjlu@umn.edu, Alan Stern <stern@rowland.harvard.edu>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org Subject: USB: storage: Fix potential NULL pointer derefernce Date: Wed, 13 Mar 2019 12:48:58 -0500 [thread overview] Message-ID: <20190313174858.23859-1-pakki001@umn.edu> (raw) Allocating memory via kcalloc for pba_to_lba and lba_to_pba can fail. The fix avoids a potential NULL pointer dereference. Signed-off-by: Aditya Pakki <pakki001@umn.edu> --- drivers/usb/storage/alauda.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index 6b8edf6178df..41d979e70784 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c @@ -438,6 +438,11 @@ static int alauda_init_media(struct us_data *us) MEDIA_INFO(us).pba_to_lba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO); MEDIA_INFO(us).lba_to_pba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO); + if (!MEDIA_INFO(us).pba_to_lba || !MEDIA_INFO(us).lba_to_pba) { + pr_warn("%s: Failed to allocate memory\n", __func__); + return USB_STOR_TRANSPORT_ERROR; + } + if (alauda_reset_media(us) != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR;
next reply other threads:[~2019-03-13 17:49 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-13 17:48 Aditya Pakki [this message] 2019-03-13 17:48 ` USB: storage: Fix potential NULL pointer derefernce Aditya Pakki 2019-03-13 18:01 ` [PATCH] " Alan Stern 2019-03-13 18:01 ` Alan Stern
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=20190313174858.23859-1-pakki001@umn.edu \ --to=pakki001@umn.edu \ --cc=gregkh@linuxfoundation.org \ --cc=kjlu@umn.edu \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-usb@vger.kernel.org \ --cc=stern@rowland.harvard.edu \ --cc=usb-storage@lists.one-eyed-alien.net \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.