From: Yury Umanets <torque@ukrpost.net>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] 2.6.6 aic79xx_osm.c: memory allocation checks
Date: Wed, 02 Jun 2004 16:24:18 +0300 [thread overview]
Message-ID: <1086182657.2898.84.camel@firefly.localdomain> (raw)
[PATCH] 2.6.6 aic79xx_osm.c: adds memory allocation checks to
drivers/scsi/aic7xxx/aic79xx_osm.c
Signed-off-by: Yury Umanets <torque@ukrpost.net>
aic79xx_osm.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 40 insertions(+), 1 deletion(-)
diff -rupN ./linux-2.6.6/drivers/scsi/aic7xxx/aic79xx_osm.c
./linux-2.6.6-modified/drivers/scsi/aic7xxx/aic79xx_osm.c
--- ./linux-2.6.6/drivers/scsi/aic7xxx/aic79xx_osm.c Mon May 10
05:32:38
2004
+++ ./linux-2.6.6-modified/drivers/scsi/aic7xxx/aic79xx_osm.c Wed Jun
2
14:31:01 2004
@@ -1565,6 +1565,8 @@ ahd_linux_dev_reset(Scsi_Cmnd *cmd)
ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
recovery_cmd = malloc(sizeof(struct scsi_cmnd), M_DEVBUF,
M_WAITOK);
+ if (recovery_cmd == NULL)
+ return (ENOMEM);
memset(recovery_cmd, 0, sizeof(struct scsi_cmnd));
recovery_cmd->device = cmd->device;
recovery_cmd->scsi_done = ahd_linux_dev_reset_complete;
@@ -2758,7 +2760,16 @@ ahd_linux_dv_target(struct ahd_softc *ah
ahd_unlock(ahd, &s);
cmd = malloc(sizeof(struct scsi_cmnd), M_DEVBUF, M_WAITOK);
+ if (cmd == NULL) {
+ printf("ahd_linux_dv_target(): Allocation of cmd is
failed\n");
+ return;
+ }
scsi_dev = malloc(sizeof(struct scsi_device), M_DEVBUF,
M_WAITOK);
+ if (scsi_dev == NULL) {
+ printf("ahd_linux_dv_target(): Allocation of scsi_dev
failed\n");
+ free(cmd, M_DEVBUF);
+ return;
+ }
scsi_dev->host = ahd->platform_data->host;
scsi_dev->id = devinfo.target;
scsi_dev->lun = devinfo.lun;
@@ -3416,14 +3427,25 @@ ahd_linux_dv_inq(struct ahd_softc *ahd,
printf("Sending INQ\n");
}
#endif
- if (targ->inq_data == NULL)
+ if (targ->inq_data == NULL) {
targ->inq_data = malloc(AHD_LINUX_DV_INQ_LEN,
M_DEVBUF, M_WAITOK);
+ if (targ->inq_data == NULL) {
+ printf("ahd_linux_dv_inq(): Allocation of "
+ "inq_data is failed\n");
+ return;
+ }
+ }
if (targ->dv_state > AHD_DV_STATE_INQ_ASYNC) {
if (targ->dv_buffer != NULL)
free(targ->dv_buffer, M_DEVBUF);
targ->dv_buffer = malloc(AHD_LINUX_DV_INQ_LEN,
M_DEVBUF, M_WAITOK);
+ if (targ->dv_buffer == NULL) {
+ printf("ahd_linux_dv_inq(): Allocation of "
+ "dv_buffer is failed\n");
+ return;
+ }
}
ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
@@ -3473,6 +3495,11 @@ ahd_linux_dv_rebd(struct ahd_softc *ahd,
if (targ->dv_buffer != NULL)
free(targ->dv_buffer, M_DEVBUF);
targ->dv_buffer = malloc(AHD_REBD_LEN, M_DEVBUF, M_WAITOK);
+ if (targ->dv_buffer == NULL) {
+ printf("ahd_linux_dv_rebd(): Allocation of "
+ "dv_buffer is failed.\n");
+ return;
+ }
ahd_linux_dv_fill_cmd(ahd, cmd, devinfo);
cmd->sc_data_direction = SCSI_DATA_READ;
cmd->cmd_len = 10;
@@ -3824,9 +3851,21 @@ ahd_linux_generate_dv_pattern(struct ahd
if (targ->dv_buffer != NULL)
free(targ->dv_buffer, M_DEVBUF);
targ->dv_buffer = malloc(targ->dv_echo_size, M_DEVBUF,
M_WAITOK);
+ if (targ->dv_buffer == NULL) {
+ printf("ahd_linux_generate_dv_pattern(): Allocation of "
+ "dv_buffer is failed.\n");
+ return;
+ }
+
if (targ->dv_buffer1 != NULL)
free(targ->dv_buffer1, M_DEVBUF);
targ->dv_buffer1 = malloc(targ->dv_echo_size, M_DEVBUF,
M_WAITOK);
+ if (targ->dv_buffer1 == NULL) {
+ free(targ->dv_buffer, M_DEVBUF);
+ printf("ahd_linux_generate_dv_pattern(): Allocation of "
+ "dv_buffer1 is failed.\n");
+ return;
+ }
i = 0;
--
umka
reply other threads:[~2004-06-02 13:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1086182657.2898.84.camel@firefly.localdomain \
--to=torque@ukrpost.net \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®